Gossamer Forum
Home : Products : Links 2.0 : Customization :

How to display ($numlinks) for Related Categories

Quote Reply
How to display ($numlinks) for Related Categories
I would like to display the total number of links available in a Related Categories. I'm using Links 2, templates and the Alternate Category mod.

I added ($numlinks) to nph-build.cgi like this - but it displays 0 (zero) links for some of the related categories. The numbers it shows are also not quite accurate if a site was included in an alternate category.

Quote:
# Calculate the related entries and put in a <LI> list.
@related = split(/\Q$db_delim\E/, $related); $related = "";
foreach $relation (@related) {
$related .= qq|<li><a href="$build_root_url/|;
$related .= &urlencode($relation);
$related .= qq|/$build_index">|;
$related .= &build_clean($relation);
$related .= "</a> ($numlinks)</li>";
}

Is it possible to count the total number of links in a category and all its subcategories? Even if the link is included in that category using the Alternate Category field?

Also, I'm using multiple templates - different ones for each category and have figured out it displays a number when I used the category.html, but a 0 for the others I have created ... even though they all are using the same code at this point.

Ideally I would like to modify the templates to include the code for the number of links for related categories, and not use nph-build.cgi. Then I could show the number for just some related categories and not others.

Confused? I am Smile Anyone have any thoughts on this?

[This message has been edited by lunaria (edited March 04, 1999).]
Quote Reply
Re: How to display ($numlinks) for Related Categories In reply to
Change ($numlinks) to $stats{$relation}[0].

When nph-build.cgi executes, the sub build_stats determines how many links apply to each category. This is kept in memory for use by other routines. Using $stats{$relation}[0] retrieves that information for you for the related categories.

I hope this helps.


[This message has been edited by Bobsie (edited March 04, 1999).]