Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Selecting A Loop?

Quote Reply
Selecting A Loop?
hi,

i've got my link template looping, but because of the way the search works I now need to have it work with two different loops (at different times).

Basically this is what I want to do...

Code:
<%if links_loop OR if link_results_loop%>
DISPLAY CONTENT
<%endloop%>

But that doesn't seem to work.

Anyone know how I can set this up to work with both - without changing the tag link_results_loop to links_loop in the search script?

Thanks,

Regan.
Quote Reply
Re: [ryel01] Selecting A Loop? In reply to
I'm not sure you can use "if" tags for loops...if you could the syntax would be:

<%if links_loop or link_results_loop%>

...however you may need to do this with perl code (a global tag or whatever)....eg...

Code:
if (scalar @{$tags->{links_loop}} or scalar @{$tags->{link_results_loop}}) ) {
return 1
}

Last edited by:

Paul: Jul 16, 2002, 3:34 PM
Quote Reply
Re: [Paul] Selecting A Loop? In reply to
thanks for that paul.

i just worked out that i need the statement to work in the loop tag itself, like...

Code:
<%loop links_loop or link_results_loop%>

no idea how to crack that one?

regan.
Quote Reply
Re: [ryel01] Selecting A Loop? In reply to
Maybe a global like:

Code:
sub {
my $tags = GT::Template->tags;
return $tags->{links_loop} || $tags->{link_results_loop};
}

Then in your template do, assuming you name your global something like "link_results_loop".

Code:
<%loop link_results_loop%> ...