Gossamer Forum
Home : Products : Gossamer Links : Discussions :

List of titles for the links

Quote Reply
List of titles for the links
Hi,

in the categories page I only need to place the list of titles for the links.
These lists must fulfill 2 conditions:

1.- only list links higher than ID = 20000
2.- if the list has less than 10 links, it should not appear

For the first condition, it works fine the following way:

-------------------------------
<%if ID > 20000%>
<div id="l<%ID%>">

<%if highlight%><%Links::Tools::highlight($Title, $query)%><%else%><%Title%><%endif%></font><%if isValidated eq 'Yes'%><%if detailed_url or URL ne 'http://'%><%endif%><%endif%>

</div>
<%endif%>
-------------------------------

How can I make it so that the list will only appear if will show at least 10 links?

Thanks in advance.

JoseML
Quote Reply
Re: [JoseML] List of titles for the links In reply to
Hi,

Try:

Code:
<%if links_loop.length >= 10%>
<%loop links_loop%>

<%if ID > 20000%>
<div id="l<%ID%>">
<%if highlight%><%Links::Tools::highlight($Title, $query)%><%else%><%Title%><%endif%></font><%if isValidated eq 'Yes'%><%if detailed_url or URL ne http://'%><%endif%><%endif%>
</div>
<%endif%>
<%endloop%>
<%endif%>

Hope that helps.

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!
Quote Reply
Re: [Andy] List of titles for the links In reply to
Hi Andy,

Thanks for the quick answer. Your suggestion works fine when there are less than 10 links on the page.

But it is not exactly what I am looking for.

I will try to sound clearer through an example:

I would like for the list of titles not to appear when 10 should appear but, for example, 7 have an ID greater than 20000 and 3 have a lower one. (or 5 links > 20000 and 5 links < 20000 or 2 links > 20000 and 8 links < 20000 or ...) Both conditions should act at the same time.

Again, thanks a lot.

JoseML
Quote Reply
Re: [JoseML] List of titles for the links In reply to
You need to first loop over the links to check to see if the first condition is satisfied. Probably something like:
Code:
<%~set enough_links = 0%>
<%~if links_loop.length >= 10%>
<%~set count = 0%>
<%~loop links_loop%>
<%~if ID > 20000%>
<%~set count += 1%>
<%~if count >= 10%>
<%~set enough_links = 1%>
<%~lastloop%>
<%~endif%>
<%~endif%>
<%~endloop%>
<%~endif%>

<%~if enough_links%>
<%~loop links_loop%>
<%~if ID > 20000%>
...
<%~endif%>
<%~endloop%>
<%~endif%>

Adrian
Quote Reply
Re: [brewt] List of titles for the links In reply to
Hi Adrian,

thanks for the concern, but I have tried your suggestion and it didnĀ“t work...

I will keep trying.

Could you tell me what this is for? ---> <%~set enough_links = 0%> and <%~if enough_links%>

Thanks.

Regards,

JoseML
Quote Reply
Re: [JoseML] List of titles for the links In reply to
It first loops over the links_loop to count how many links match your requirement of having an ID of greater than 20000.

I guess it could actually be simplified to:
Code:
<%~set matching_links = 0%>
<%~if links_loop.length >= 10%>
<%~loop links_loop%>
<%~if ID > 20000%>
<%~set matching_links += 1%>
<%~if matching_links >= 10%>
<%~lastloop%>
<%~endif%>
<%~endif%>
<%~endloop%>
<%~endif%>

<%~if matching_links >= 10%>
<%~loop links_loop%>
<%~if ID > 20000%>
...
<%~endif%>
<%~endloop%>
<%~endif%>

Adrian

Last edited by:

brewt: Aug 5, 2008, 8:35 PM
Quote Reply
Re: [brewt] List of titles for the links In reply to
Thanks Adrian !!!! it works great.

Cheers,

JoseML