Gossamer Forum
Home : Products : Links 2.0 : Customization :

If there are no links in a category, do this...

Quote Reply
If there are no links in a category, do this...
Is there a way, using templates, to have a category with no links in it say something like:

--- there are no links in this category ---

???

------------------
Quote Reply
Re: If there are no links in a category, do this... In reply to
In site_html_print_cat, I would just check $numlinks to see if it is less than 1 and, if it is, assign your statement to it instead of displaying the 0. For example:

Code:
if ($numlinks < 1) {
$numlinks = "--- there are no links in this category ---"; }

You might need to put a <br> in that at the beginning to fit it in the display.

That way, you don't need to make any changes in the template file.

I hope this helps.

[This message has been edited by Bobsie (edited March 14, 1999).]
Quote Reply
Re: If there are no links in a category, do this... In reply to
Thank Bobsie. I added it to site_html_category instead so if there are no links in a category it says that on the page with no links. Thanks,

Nicholas

------------------
Quote Reply
Re: If there are no links in a category, do this... In reply to
Or, if you've installed the <%ifnot ..%> template mod you could just do:

<%if link_results%>
Here are your links:
<%link_results%>
<%endif%>
<%ifnot link_results%>
Sorry, no links here.
<%endif%>

Cheers,

Alex
Quote Reply
Re: If there are no links in a category, do this... In reply to
Alex,

I think the ifnot call is incorrect. Should it not be <%ifisnot ...%>

Anyway, I included the code for ifnot provided in the other forum by "cal" and included this in my category.html
<%if links%>
<%links%>
<%endif%>
<%ifisnot links%>
Sorry, no resources are listed in this category at this time.
<%endif%>
====
Does not seem to be working. Anybody knows?
Quote Reply
Re: If there are no links in a category, do this... In reply to
Seems to me (mind you, from the point of view of a Perl moron) that either your version or Alex's would be wrong because in either case you do not have an <%if...%> statement, so you can't zactly <%endif%>. You'd have to <%endifnot%> or whatever the statement started as.

Phoenix
Quote Reply
Re: If there are no links in a category, do this... In reply to
 
Quote:
Anyway, I included the code for ifnot provided in the other forum by "cal" and included this in my
category.html
<%if links%>
<%links%>
<%endif%>
<%ifisnot links%>
Sorry, no resources are listed in this category at this time.
<%endif%>
====
Does not seem to be working. Anybody knows?

First, you said that you used <%ifnot ..%> but your code still says <%ifisnot ..%>.

Second, in order to use <%ifnot ..%>, you need to download the updated links2.zip and install the new Template.pm.

Phoenix,

The <%endif%> tag applies to both <%if ..%> and <%ifnot ..%>. They are both "if" statements.
Quote Reply
Re: If there are no links in a category, do this... In reply to
Bobsie,

======
First, you said that you used <%ifnot ..%> but your code still says <%ifisnot..%>.
======
Yes, first I tried <%ifnot...%> nothing beyond the firt <%endif%> was loading on the page (loop not completed? my knowledge of programming is limited).

Then I tried <%ifisnot...%> while, the page loaded completely this time, the statement it was supposed print was not being displayed.

=====
Second, in order to use <%ifnot ..%>, you need to download the updated links2.zip and install the new Template.pm.
=====
I have already modified the Template.pm according to the instructions posted by "Cal" in the following forum and hence tried this following instructions by Alex in the same post.

http://www.gossamer-threads.com/...um3/HTML/000687.html

====
you need to download the updated links2.zip
====
I am using the links2.0 final. Is there a new updated version? This is news to me.

Appreciate your response.

Phoenix,

Check out the post link above, if you are interested.
Quote Reply
Re: If there are no links in a category, do this... In reply to
Ok, just to clear somethings up:

1. It's <%ifnot variable%> and not <%ifisnot%>.

2. There is never any reason to do this:

<%if links%>
<%links%>
<%endif%>

It's just slowing the parsing down. When you think about it, your saying print the contents of links if it is not blank. Well if it is blank, then there's no harm in printing it?

3. Bobsie's right, the <%endif%> tag ends the previous if or ifnot statement.

Cheers,

Alex
Quote Reply
Re: If there are no links in a category, do this... In reply to
Gentlemen,

To clear something up, first - I am using that <%if links%> at the beginning because I am using a <hr> in between and a table in my template. So, the table and the line is displayed only if there are links listed.

Once again, my knowledge of programming is limited. Here is what I construe from the above post, in order to accomplish the task ie. print "there are no links" if there are no links in a given category.

So, all I need is:

<%links%>
<%ifnot links%>
Sorry, there are no links listed in this category.
<%endif%>

If this is correct, then just to let you know I already tried this. Does not work. Now what?

Appreciate a reply.
Quote Reply
Re: If there are no links in a category, do this... In reply to
Socrates,

From what I understand you need the following:

<%if link%>
<hr>
<%endif%>
<%ifnot links%>
Sorry, no links here.
<%endif%>

I didn't follow what else you wanted if there are links present, so
I just put <hr>. If this doesn't solve your problem, make sure you
have the variable name right. (did you change it? is it capitalized?)

Hope this helps,
Cal
cal@calsweb.com
Quote Reply
Re: If there are no links in a category, do this... In reply to
Cal,

Thanks for your reply. As you mentioned, I tried this again.

<%ifnot links%>
Sorry, no links here.
<%endif%>

Still does not work. Essentially nothing in the bottom part of my page is printed (I have a footer)

=========
If this doesn't solve your problem, make sure you have the variable name right. (did you change it? is it capitalized?)
===========

Yes, checked it (inserted just the above code in my category.html)

Questions:
1. The link that posted in above in my previous post, wherein you put the code for this purpose, is that the only modification needed in templates.pm? By the way I copied that whole subroutine as posted at stangnet.com

2. Is this working on your site ie if you paste the above <%ifnot...%> in your site, is it printing the the statement that follows?

Thanks
Quote Reply
Re: If there are no links in a category, do this... In reply to
Socrates,

I figured out your problem and it isn't with your code. It
is with my mod to allow for nested ifs. I don't see my error
right off and I am going out of town for the weekend, so change
parse in Template.pm back to the way it was before the nested
ifs. If you didn't back up it up, I have posted it at http://www.calsweb.com/nested.html .

Sorry about the trouble, and I hope this helps.
Cal
cal@calsweb.com
Quote Reply
Re: If there are no links in a category, do this... In reply to
No Problem, Cal. If you get it work let us know.
Quote Reply
Re: If there are no links in a category, do this... In reply to
I installed new sub parse in the Templates.pm for bed to ifnots and am with problems...

I added in category.htm:

<%if links%>
<%links%>
<%endif%>
<%ifnot links%>
NO links on this category
<%endif%>

To put, this having some problem that when control to generate the pages in HTML it is
INCOMPLETE!

It does not appear NOTHING beyond <%ifnot... %>... But the things that are BEFORE appear...

Necessary of AID!