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

Re: [AMIXIMA] links_loop inside category_loop

Quote Reply
Re: [AMIXIMA] links_loop inside category_loop In reply to
Hi,

Are you saying you want to do a loop of <%category_loop%>, and inside that , then loop the links for that category? If so, you could do it with a new global:

get_cat_links
Code:
sub {

my $cat = shift;
my $all_ids = $DB->table('Category')->children($cat);
push @$all_ids, $cat;

my $db_obj = $DB->table('Links','CatLinks','Category');
$db_obj->select_options ('ORDER BY Title DESC LIMIT 20');

my $cond = GT::SQL::Condition->new('CategoryID', 'IN', $all_ids);
my $cond2 = GT::SQL::Condition->new('isValidated','=','Yes');
my $sth = $db_obj->select (['Links.*'], $cond, $cond2 ) || die $GT::SQL::error;

my @cats;
while (my $hit = $sth->fetchrow_hashref) {
$link = Links::SiteHTML::tags('link', $link);
push @cats, $hit;
}

return { link_sub_loop => \@cats }

}

Then call something like:
Code:
<%loop category_loop%>
<%include subcategory.html%>
<%get_cat_links ($ID)%>
<%if link_sub_loop.length%>
<%loop link_sub_loop.length%>
<%include link.html%>
<%endloop%>
<%endif%>

Untested, but it should work Smile

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Subject Author Views Date
Thread links_loop inside category_loop AMIXIMA 4364 May 28, 2012, 8:17 AM
Thread Re: [AMIXIMA] links_loop inside category_loop
Andy 4238 May 29, 2012, 12:39 AM
Thread Re: [Andy] links_loop inside category_loop
AMIXIMA 4202 May 30, 2012, 11:39 AM
Post Re: [AMIXIMA] links_loop inside category_loop
Andy 4260 May 30, 2012, 11:47 AM