Gossamer Forum
Home : Products : Links 2.0 : Discussions :

How to create a 'This category is empty' message with templates...

Quote Reply
How to create a 'This category is empty' message with templates...
I've looked through several threads (and searches in the forum) and assume it's an easy question to answer but haven't found exactly what I'm looking for...

How can I create a "This category is empty" message for categories that have no links in them?

I am using templates and assume that there is going to be an IF statement in the answer but I'm still getting up to speed on IF, etc.
Quote Reply
Re: How to create a 'This category is empty' message with templates... In reply to
It would be something like

Code:
<%ifnot links%> This category is empty<%endif%>

You probably know you'd have to put this where you want it to say the text. Don't forget to put <%endif%> on a new line. Oh, and you put this in the category.html file if you don't know. Hope this helps. Tell me if it works. And to be able to use the ifnot command, you need to go to the Resources center and get the nested ifs mod for templates.


------------------------------------------
Lavon Russell
LookHard! Search
www.lh.yi.org
webmaster@lh.yi.org


[This message has been edited by Bmxer (edited July 30, 1999).]
Quote Reply
Re: How to create a 'This category is empty' message with templates... In reply to
That didn't seem to do it. Do I need a special mod installed? Thanks....
Quote Reply
Re: How to create a 'This category is empty' message with templates... In reply to
As he said in the previous note, you have to have the nested if mods installed -- it's in the resource center.
Quote Reply
Re: How to create a 'This category is empty' message with templates... In reply to
Yes, thanks pug, but I just figured out what was wrong as I've enabled it on my site. I'll try to give full description.

Like i said before, put that ifnot call on your category page, but change it so it reads
Code:
<%ifnot links%> <%nolinks%>
<%endif%>
Remember to put endif on a new line

Don't build yet.
Put this tag in the sub site_html_category in site_html_templates.pl
Code:
nolinks => $nolinks,

That should enable you to use nolinks.

Then in the links.cfg file, maybe in the
# Paths and URL's to Important Stuff section
before database options, put this code

Code:
# Text for a category with no links.
$nolinks ="This category has no links";
. Um, that should be enough to work. You can later on fix it up with fonts and stuff, but i wanna see if it works for you.

------------------
------------------------------------------
Lavon Russell
LookHard! Search
http://www.lh.yi.org
webmaster@lh.yi.org
Quote Reply
Re: How to create a 'This category is empty' message with templates... In reply to
Best place for putting those variables ($nolinks) is in templates.cfg if you use that, or site_html_templates.pl if you don't, for organizational reasons. This is not a mod to Links proper, but the output routines in site_html*.pl and templates.cfg.

as for nolinks => $nolinks,

Enter it into the %globals arrary, and it will be available to all routines and templates.

Other than that, the mod works perfectly, I just tested it out by adding it to my links.
Quote Reply
Re: How to create a 'This category is empty' message with templates... In reply to
yeah, thanks, it fooled me at first because i don't get the globals area. I add stuff to it but it always messes me up. I didn't wanna say too much because i don't know where he puts stuff in the templates.cfg or site_html_templates, i myself use site. Pug, In Links.cfg did you put the text i said in a different place because i don't like it where it is and want to know if it works anywhere else?

Oh and where do i get templates.cfg?

------------------
------------------------------------------
Lavon Russell
LookHard! Search
http://www.lh.yi.org
webmaster@lh.yi.org
Quote Reply
Re: How to create a 'This category is empty' message with templates... In reply to
Thanks, worked great! To take this one step further, I only want to display the 'There are no links in this category' message in categories that do NOT contain more subcategories.

The second level of my directory tree only contains subcategories and will never contain links so I don't want that message to show there. To clarify:

Home - contains only categories (no nolinks message)
2nd level - List of Subcategories (no links listed but does NOT have nolinks message)
3rd Level - Bottom level (contains no subcats but HAS nolinks message)


Thanks a ton for your help...

[This message has been edited by SpartyOn (edited July 31, 1999).]

[This message has been edited by SpartyOn (edited July 31, 1999).]
Quote Reply
Re: How to create a 'This category is empty' message with templates... In reply to
That sounds pretty easy, all u would have to do would be to call
Code:
<%ifnot category%>
<%nolinks%>
<%endif%>
but that can't do it because you probably want links in level 3, and if you have links but no categories, that tag will call the Nolinks message. Let me think about this.

Sorry if you were telling me what you did and not asking for help this time.

------------------
------------------------------------------
Lavon Russell
LookHard! Search
www.lh.yi.org
webmaster@lh.yi.org


[This message has been edited by Bmxer (edited July 31, 1999).]

[This message has been edited by Bmxer (edited July 31, 1999).]
Quote Reply
Re: How to create a 'This category is empty' message with templates... In reply to
Ok, forget the thinking about it, it was very obvious
Just put
Code:
<%ifnot category%><%ifnot links%><%nolinks%>
<%endif%><%endif%>
See you just call both things so if theres links but no categories, it won't display it. And vice-versa. The only time it will display the nolinks message is if you hit the very bottom of maybe (on mine) 4 subcategories. Which is where there is no links or categories. I hope this is what you meant.

------------------
------------------------------------------
Lavon Russell
LookHard! Search
http://www.lh.yi.org
webmaster@lh.yi.org
Quote Reply
Re: How to create a 'This category is empty' message with templates... In reply to
Worked like a charm! Thanks a ton for the help guys!