I want to place a category title (title_linked tag) above a search.cgi result but ONLY if the category has changed, i.e. every link searched is associated with a category using the title_linked variable in the link_loop_results. However, I'm not sure how to check if it has changed because you need to compare with the previous/next iteration of the loop.
Here's what I got so far but it doesn't seem to work exactly...
<%loop link_results_loop%>
<%if first%> <%-- set up the opening table --%>
<TABLE>
<TR>
<%endif%>
<%--
Check if link is in a new category, if so display it
--%>
<%if prevcat%>
<%if prevcat != $title_linked%>
<TR><TD><span class="hi_orange"><%title_linked%></span><br></TD></TR>
<%endif%>
<%else%>
<%set prevcat = $title_linked%>
<TR><TD><span class="hi_orange"><%title_linked%></span><br></TD></TR>
<%endif%>
<%-- Pull Individual Link Format --%>
<TD>
<%include linkGallery.html%>
</TD>
<%ifnot row_num % 4%> <%-- close the row --%>
</TR>
<%endif%>
<%if last%> <%-- close the table --%>
<%if row_num % 4 eq 1%> <%-- balance the trailing rows --%>
<TD></TD><TD></TD>
<%endif%>
<%if row_num % 4 eq 2 %> <%-- balance the trailing rows --%>
<TD></TD>
<%endif%>
</tr>
</TABLE>
<%endif%>
<%endloop%>
Here's what I got so far but it doesn't seem to work exactly...
Code:
<%loop link_results_loop%>
<%if first%> <%-- set up the opening table --%>
<TABLE>
<TR>
<%endif%>
<%--
Check if link is in a new category, if so display it
--%>
<%if prevcat%>
<%if prevcat != $title_linked%>
<TR><TD><span class="hi_orange"><%title_linked%></span><br></TD></TR>
<%endif%>
<%else%>
<%set prevcat = $title_linked%>
<TR><TD><span class="hi_orange"><%title_linked%></span><br></TD></TR>
<%endif%>
<%-- Pull Individual Link Format --%>
<TD>
<%include linkGallery.html%>
</TD>
<%ifnot row_num % 4%> <%-- close the row --%>
</TR>
<%endif%>
<%if last%> <%-- close the table --%>
<%if row_num % 4 eq 1%> <%-- balance the trailing rows --%>
<TD></TD><TD></TD>
<%endif%>
<%if row_num % 4 eq 2 %> <%-- balance the trailing rows --%>
<TD></TD>
<%endif%>
</tr>
</TABLE>
<%endif%>
<%endloop%>