Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Need help with loop

Quote Reply
Need help with loop
Hi,

The following works, but Test Loop (Header) shows up on page 2 even if there is no links available. I assume the same would happen for Test Loop Two (Header).

Questions:

1. Can I stop the Header from showing when no links available.
2. Can I shorten the code and obtain the same results.



<%if link_results_loop.length~%>
<h3>Test Loop:</h3><br>
<%if title_loop.length%>
<%~set formatted_title = Links::Utils::format_title($title_loop, separator => $category_separator, no_escape_separator => $no_escape_category_separator, include_home => 0, link_type => 1)%>
<p class="category"><%if highlight and query%><%Links::Tools::highlight($formatted_title, $query)%><%else%><%formatted_title%><%endif%></p>
<%~endif%>
<%loop link_results_loop~%>
<%if test eq '3'~%>
<%include link.html%>
<%~endif%>
<%~endloop%>
<br>
<%if link_results_loop.length~%>
<h3>Test Loop Two:</h3><br>
<%if title_loop.length%>
<%~set formatted_title = Links::Utils::format_title($title_loop, separator => $category_separator, no_escape_separator => $no_escape_category_separator, include_home => 0, link_type => 1)%>
<p class="category"><%if highlight and query%><%Links::Tools::highlight($formatted_title, $query)%><%else%><%formatted_title%><%endif%></p>
<%~endif%>
<%loop link_results_loop~%>
<%if test eq '5' or test eq '4' or test eq '2' or test eq '1' or test eq '0'~%>
<%include link.html%>
<%~endif%>
<%~endloop%>
Quote Reply
Re: [rascal] Need help with loop In reply to
I can't tell what you are trying to do, but you are missing 2 <%~endif%> 's at the end of that code. It doesnt balance.

Are you trying to do it like this? I rearranged the endif's
Code:
<%if link_results_loop.length~%>
<h3>Test Loop:</h3><br>
<%if title_loop.length%>
<%~set formatted_title = Links::Utils::format_title($title_loop, separator => $category_separator, no_escape_separator => $no_escape_category_separator, include_home => 0, link_type => 1)%>
<p class="category"><%if highlight and query%><%Links::Tools::highlight($formatted_title, $query)%><%else%><%formatted_title%><%endif%></p>
<%~endif%>

<%loop link_results_loop~%>
<%if test eq '3'~%>
<%include link.html%>
<%~endif%>
<%~endloop%>
<%~endif%>

<br>

<%if link_results_loop.length~%>
<h3>Test Loop Two:</h3><br>
<%if title_loop.length%>
<%~set formatted_title = Links::Utils::format_title($title_loop, separator => $category_separator, no_escape_separator => $no_escape_category_separator, include_home => 0, link_type => 1)%>
<p class="category"><%if highlight and query%><%Links::Tools::highlight($formatted_title, $query)%><%else%><%formatted_title%><%endif%></p>
<%~endif%>

<%loop link_results_loop~%>
<%if test eq '5' or test eq '4' or test eq '2' or test eq '1' or test eq '0'~%>
<%include link.html%>
<%~endif%>
<%~endloop%>
<%~endif%>



Chris
RGB World, Inc. - Software &amp; Web Development.
rgbworld.com

Last edited by:

rgbworld: May 30, 2005, 9:16 PM
Quote Reply
Re: [rgbworld] Need help with loop In reply to
Thank you Sir for finding the two errors.

I hope the following will explain what I'm trying to do:

Code works fine except when you go to the next 25 links the Header shows when no links are available.


Test Loop:

No links available, so I do not want Test Loop Header to Display, but it does.


Test Loop Two:


links available, so Header should display.