Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

need a help to mod this great global.

Quote Reply
need a help to mod this great global.
im using this global to call "similar links" in detailed page(its showing random selected links from Father category on detailed page):

global name: diff_detail
Code:
sub {
my $ID = $_[0];
my $table = $DB->table('CatLinks');
my $sth = $table->select( { LinkID => $ID } ) or return $GT::SQL::error;
my $CatID;
while (my $hit = $sth->fetchrow_hashref) { $CatID = $hit->{CategoryID};
}
return { FatherID => $CatID };
}

in detailed.html im calling it with

Code:
<%diff_detail($ID)%>
<table>
<%include include_detailed_similar.html%></table>

include_detailed_similar.html:

Code:
<%if FatherID eq 'CatID'%>
<%set Random_CatID =1'%>
<%pop%>
<%loop Random_Loop%>
<%include link_similar.html%>
<%endloop%><%elseif FatherID eq '2'%>
<%set Random_CatID ='2'%>
<%pop%>
<%loop Random_Loop%>
<%include link_similar.html%>
<%endloop%>
<%elseif FatherID eq '3'%>
<%set Random_CatID ='3'%>
<%pop%>
<%loop Random_Loop%>
<%include link_similar.html%>
<%endloop%>
<%elseif FatherID eq '4'%>
<%set Random_CatID ='4'%>
<%pop%>
<%loop Random_Loop%>
<%include link_similar.html%>
<%endloop%>ETC.
<%endif%>

link_similar.html - just a copy of link.html
its working well when I have 50 categories.
but if i have 1000 categories, its generating 4MB file(detailed.compiled) and as a result overloaded a server.

guys, please help to hack it to make it 1000 categories friendly.
Quote Reply
Re: [hmc] need a help to mod this great global. In reply to
There must be a way to write the template bit more consisely - what about

<%set Random_CatID = $FatherID%>
<%pop%>
<%loop Random_Loop%>
<%include link_similar.html%>
<%endloop%>

Quote Reply
Re: [afinlr] need a help to mod this great global. In reply to
thanks!