Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Loop support?

Quote Reply
Loop support?
In the announcements for v2.05 there is mentioned full loop support.
How can this be used?

Quote Reply
Re: Loop support? In reply to
Example codes have already been posted in this forum before...search for loop in this forum.

Regards,

Eliot Lee Wink
http://anthrotech.com/
Quote Reply
Re: Loop support? In reply to
And there are samples and instruction within the LinksSQL help files to help you.

________________________
Eraser
Insight Eye
http://www.insighteye.com
Quote Reply
Re: Loop support? In reply to
The best examples are the default template sets themselves. The on-line help in the "Templates" module also has additional information.

Loops are very powerful, and combined with template functions, essentially duplicate the power of emb_perl, and quite a bit of PHP. They really un-link the templates from the scripts, and you can almost embed programs in the template system without having .cgi scripts at all.

PUGDOGŪ Enterprises, Inc.
FAQ:http://LinkSQL.com/FAQ
Plugins:http://LinkSQL.com/plugin
Quote Reply
Re: Loop support? In reply to
I was thinking if I could do the following without using the sorting in the admin interface:
I have a custom field in the links table for sponsored sites. At the moment I use the sorting to display these links first and with a different layout, so I was wondering if using the loop feature I could display those links in a separate section in the beginning of the category pages and the search results. That way it could be specified in each separate template set if the sponsored links have to be displayed first or not.

Quote Reply
Re: Loop support? In reply to
Yes, you could do:

Sponsored Links:
<%loop link_results_loop%>
<%if isSponsored eq 'Yes'%>
<%include link.html%>
<%endif%>
<%endloop%>

Regular Links:
<%loop link_results_loop%>
<%if isSponsored eq 'No'%>
<%include link.html%>
<%endif%>
<%endloop%>

Does that make sense? Let me know if you have a question..

Cheers,

Alex

--
Gossamer Threads Inc.
Quote Reply
Re: Loop support? In reply to
Alex,
while the loops work properly for displaying a different layout, they do not work to group the results in the beginning: results of each page get grouped in the beginning of the page they belong.

Any solution? Because the main advantage of the loops would be the group sorting without using the sort feature from the admin interface, otherwise the layout could be differentiated through the link.html template

Also I am wondering if this is used extensively, for example to display a few different layouts of links in the search results, could significantly delay the display of results.

If someone would like to have the title "Sponsored Links" dislayed only if there are sponsored links in this category? So I came up with:
<%loop links_loop%>
<%if isSponsored eq 'Yes'%>
Sponsored sites:
<%lastloop%>
<%endif%>
<%endloop%>

Is that correct or there is a different way it should be done?
Quote Reply
Re: Loop support? In reply to
Hi,

Yes, the loop only has the links on that page. On category pages for example, in link_results_loop, you only have the first page of links, not all the links available. This means if there are featured links later, you can't access them.

To do what you want, you should sort by isSponsored first, and then alphabetically. Then you could use the code I posted to display the sponsored ones first.

Cheers,

Alex

--
Gossamer Threads Inc.
Quote Reply
Re: Loop support? In reply to
Is there any other way to sort the links, as using the sort feature in the admin this reflects this order to all the template sets? I would like to have the sponsored links displayed separately in the default template set but not in the other sets.