Gossamer Forum
Home : Products : Links 2.0 : Customization :

Total number of Links in Category

Quote Reply
Total number of Links in Category
I'm trying to use the <%total%> variable to show the total number of links in each category and sub category.

All the sub category pages display the correct amount of links.

The main category pages do not. They all show 0 links even though the sub categories under them have links in them.

What could be causing this problem? How do I fix it?
Quote Reply
Re: [troyid] Total number of Links in Category In reply to
I'm willing to pay $20 US dollars or equivalent to anyone that can resolve this problem.
Quote Reply
Re: [troyid] Total number of Links in Category In reply to
I wanted to bring this to the top of the posts again. It has not been resolved and I have searched the forums and it seems like others have experienced this problem without a conclusion.

Can someone help?
Quote Reply
Re: [troyid] Total number of Links in Category In reply to
Do you mean...

The main (home) page which lists all top level categories dhows the number of links in it:

Main Category (50)

But if you go that category, subcats under it show zero:

Main Category
Sub Cat One (0)
Sub Cat Two (0)

But it should be:

Main Category
Sub Cat One (25)
Sub Cat Two (25)

Is this the problem? The code works fine on my site, see this page which would be the equivalent of the third example above:
http://theonetruechurch.com/.../Spreading_the_Word/

Have you made changes to the code? This code from site_html_templates.pl, sub site_html_print_cat, is what puts the count in place, and it's not <%total%>:

# First let's get the name, number of links, and last modified date...
$url = "$build_root_url/" . &urlencode($subcat) . "/";
if ($subcat =~ m,.*/([^/]+)$,) { $category_name = &build_clean($1); } else { $category_name = &build_clean($subcat); }
$numlinks = $stats{"$subcat"}[0];
$mod = $stats{"$subcat"}[1];

...more code...

# Then we print out the name linked, new if it's new, and popular if its popular.
$output .= qq|<dl><dt><strong><a class="link" href="$url">$category_name</a></strong> <small class="numlinks">($numlinks)</small> |;
$output .= qq|<small><sup class="new">new</sup></small>| if (&days_old($mod) < $db_new_cutoff);
$output .= qq|</dt>|;
$output .= qq|<dd><span class="descript">$description </span></dd>| if (!($description =~ /^[\s\n]*$/));
$output .= qq|</dl>|;


Does your code look like this?


Leonard
aka PerlFlunkie

Last edited by:

PerlFlunkie: May 8, 2004, 1:32 AM
Quote Reply
Re: [troyid] Total number of Links in Category In reply to
Or maybe this is what you want...not really sure, though..Tongue
http://www.gossamer-threads.com/...ks%20category;#30402
Quote Reply
Re: [cloud^77] Total number of Links in Category In reply to
Neither of these answers my question.

I have included this in my category.html template.

"There are currently <b><%total%></b> links for you to choose from"

This code works OK in my sub-categories but it does not work properly in my main category, meaning it does not count all the links in the sub-categories of the main category.

Take a look at http://dmoz.org/Computers/Internet/ for example. See how it counts all links that are in the sub-categories of this category.
Quote Reply
Re: [troyid] Total number of Links in Category In reply to
According to the template help...
  • <%total%> : Total number of new links.
  • <%grand_total%> : The total number of links in the database.



  • Perhaps you need the second option?


    Leonard
    aka PerlFlunkie
    Quote Reply
    Re: [PerlFlunkie] Total number of Links in Category In reply to
    No. That is not what I want. Grand Total would give me the total of all links in my database. I want the grand total of all links in individual categories.