Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Simple If question

Quote Reply
Simple If question
Hi

I would like when user click on some category and 10 OR MORE links are shown, search bar to be shown at the bottom of the page. ( <%include include_search_bar.html%>)

Othervise, to not show the search bar on the bottom of the page.

I guess that is one simple if line, but I don't know Perl Blush

I would like to have this future and on search results, if more than 10 results are returned.

Regards, Zoran
Quote Reply
Re: [Zoran] Simple If question In reply to
I don't know if this is the best way, but I think you can do it by placing the following loop code at the top of the category.html template page (This would count the number of links):

<%set Link_Counter = 0%>
<%loop links_loop%>
<%set Link_Counter += 1%>
<%endloop%>

Then you can place the search bar at the bottom somewhere with:

<%if Link_Counter > 9%>
<%include include_search_bar.html%>
<%endif%>

--FrankM

Last edited by:

FrankM: Jun 28, 2004, 12:18 PM
Quote Reply
Re: [Zoran] Simple If question In reply to
Or, something like;

<%if link_hits > 9%>
show search bar
<%endif%>

:)

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] Simple If question In reply to
Hi Guys

Thanks for the response.

Frank solution works fine.

Code posted by Andy didn't work, I dont know the reason.

No error message, just didn't show the search bar at bottom on the page. I guess I did something wrong but I don't know what.

However code posted by Andy should give better performance if I can manage to work, because avoid the counting.

Andy , can you please tell me what is link_hits ?? I didn't find link_hits on category.html?

Thanks, Zoran
Quote Reply
Re: [Zoran] Simple If question In reply to
Sorry, I thought you were refering to a search page :(

In that case, for category.html, it should be <%Number_of_Links%>.

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] Simple If question In reply to
I needed code for both pages!
I test your code on category.html page, that's why didn't work.Blush

So I have the code for both pages? Great! Cool

Thanks, Zoran
Quote Reply
Re: [Zoran] Simple If question In reply to
The <%Number_of_Links%> tag is definitely simpler and more efficient. Just keep in mind with the <%Number_of_Links%> tag for the category page is that it not only counts the total number of links in that specific category, but it also counts all of the links in any of its sub-categories.

So if the Main Category has 3 links in it, and it has one Sub-Category with 20 links in it, I think the <%Number_of_Links%> tag will return '23' for the Main Category and '20' for the Sub-Category. So it would then show the search form on the Main Category page eventhough there are actually only 3 links in that specific main category. Depending on your directory structure, or goals, this might not be an issue for you though.

--Frank

Last edited by:

FrankM: Jun 29, 2004, 11:43 AM
Quote Reply
Re: [FrankM] Simple If question In reply to
Hi Frank

Thanks Frank. I just check it and yes, you are right about that.
What I did is :
I use your code (with counter) in category.html and code posted by Andy I use in search_results.html and it works just fine.

However I still wory about the performance, since my site is not on dedicated server :-(

Thanks for the help...

Regards, Zoran
Quote Reply
Re: [Zoran] Simple If question In reply to
Yes, I don't know how much processing power it takes. I don't think it takes much, but I really don't know... One thing you could do to lessen it for categories with a lot of links is to exit the loop as soon as it counts more than 9 links:

<%set Link_Counter = 0%>
<%loop links_loop%>
<%set Link_Counter += 1%>
<%if Link_Counter > 9%>
<%lastloop%>
<%endif%>
<%endloop%>

That way if there were 20 links in there it wouldn't count all 20 but as soon as it got to 10 would stop the counting.

--Frank
Quote Reply
Re: [FrankM] Simple If question In reply to
Hi Frank

Thanks for the effort. I will implement this code later today. I have no possibility to check the perfromance, but it should save some resources.

Regards,Zoran