Gossamer Forum
Home : Products : Gossamer Links : Discussions :

If statement to display message

Quote Reply
If statement to display message
Instead of displaying an empty page if no links are in a subcategory, I would like to display a message in that empty subcategory page. I don't mind the empty page displaying, I'd just like to insert a message with it, such as:
Code:
<%if Number_of_Links > 0%> No links to display at this time. <%endif%>
When I use this in the subcategory template, it shows up on the main category/subcategory listing under many links. I just want it to show up on that empty subcategory's page. I looked at the category.html and link.html templates, but I don't see a place to insert this code. Is there a better way to go about producing this message?

Thanks,
WG
Quote Reply
Re: [Westiegirl] If statement to display message In reply to
In category.html, do something like:

Code:
<%if links_loop.length > 0%>
...do the normal <%loop links_loop%> stuff here
<%else%>
There are no links here..
<%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] If statement to display message In reply to
Hi Andy,
Thanks for your help. I tried it the way it is here and also with <%if links_loop.length > 0%> before the first two lines. Unfortunately, neither worked. Any other help would be most appreciated!
Code:
<%if links_loop.length~%>
<h3>Links</h3>
<%if paging.num_hits%><div class="paging"><%Links::Utils::paging()%></div><%endif%>
<%if links_loop.length > 0%>
<%loop links_loop~%>
<%include link.html%>
<%~endloop%>
<%else%>
There are no links here.
<%endif%>
<%if paging.num_hits%><div class="paging"><%Links::Utils::paging(button_id => 'paging_button2')%></div><%endif%>
<%~endif%>
Quote Reply
Re: [Westiegirl] If statement to display message In reply to
MMm, this should work:

Code:
<%if links_loop.length > 0%>
<%loop links_loop~%>
<%include link.html%>
<%~endloop%>
<%else%>
There are no links here.
<%endif%>

Try this:

Code:
<%if links_loop.length > 0%>
<%loop links_loop~%>
<%include link.html%>
<%endloop%>
<%else%>
There are no links here.
<%endif%>

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] If statement to display message In reply to
I tried them both again and neither worked. Could it be the operator sign? I was never really good at greater than, less than... Blush
Quote Reply
Re: [Westiegirl] If statement to display message In reply to
Hi,

Can you try with "link_loop", instead of "links_loop"

The condition is fine > just means "greater than"

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] If statement to display message In reply to
Thanks, Andy. I tried it on this line but it didn't work:
<%if link_loop.length > 0%>

Should I have tried it on a different line?
Quote Reply
Re: [Westiegirl] If statement to display message In reply to
What do you see when you put:

<%DUMP links_loop%>


?

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] If statement to display message In reply to
Sorry... I tried it in a few places but nothing happened. I wasn't sure where to add that line though.
Quote Reply
Re: [Westiegirl] If statement to display message In reply to
Hi,

Should work anywhere in the template

What version are you running?

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] If statement to display message In reply to
Wait, your code works for adding that line! Sorry. Operator error! Blush

I am now trying to do the same thing for empty categories but that doesn't seem to be working or I'm looking in the wrong place. Any hope in getting this one to work?
Code:
<%if category_loop.length~%>
<h3>CATEGORIES:</h3>
<%~set split = Links::Utils::column_split($category_loop.length, $category_cols)%>
<div class="clear">
<%if category_loop.length > 0%>
<%loop category_loop%>
<%~set splitmod = $row_num % $split%>
<%~if row_num == 1 or splitmod == 1 or split == 1%><dl><%endif%>
<%~include subcategory.html%>
<%~if row_num == $category_loop.length or splitmod == 0%></dl><%endif%>
<%~endloop%>
<%else%>
There are no categories yet.
<%endif%></div>
<%~endif%>
Quote Reply
Re: [Westiegirl] If statement to display message In reply to
haha cool :)

For the categories, you need it like so:

Code:
<%if category_loop.length~%>
<h3>CATEGORIES:</h3>
<%~set split = Links::Utils::column_split($category_loop.length, $category_cols)%>
<div class="clear">
<%loop category_loop%>
<%~set splitmod = $row_num % $split%>
<%~if row_num == 1 or splitmod == 1 or split == 1%><dl><%endif%>
<%~include subcategory.html%>
<%~if row_num == $category_loop.length or splitmod == 0%></dl><%endif%>
<%~endloop%>
</div>
<%else%>
There are no categories yet.
<%~endif%>

If you look at the top of the code you posted, it already has an <%if category_loop.length> 0%> bit , which is why your code was never run =)

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] If statement to display message In reply to
Success!

I think the same thing happened with the links code ? So instead, I used this:
Code:
<%if links_loop.length~%>
<h3>Links</h3>
<%if paging.num_hits%><div class="paging"><%Links::Utils::paging()%></div><%endif%>
<%if links_loop.length < 1%>
There are no links here.
<%else%>
<%loop links_loop~%>
<%include link.html%>
<%~endloop%>
<%endif%>
<%if paging.num_hits%><div class="paging"><%Links::Utils::paging(button_id => 'paging_button2')%></div><%endif%>
<%~endif%>

Thanks so much for all your help, Andy!