Gossamer Forum
Home : Products : Links 2.0 : Customization :

Number of Categories?

Quote Reply
Number of Categories?
I installed the Number of Categories & Number of Links
Mod as outline in the FAQ. My question is, will <%numcat%> and <%numlinks%> tags be effected where there place in a template?

After testing the Mod I get Unkown Tag: shown in the browser for category.html. Sample code from template:
<%if category%>
<%numcat%> <b>Categories:</b>
<% category %>
<%endif%>

TIA



Quote Reply
Re: Number of Categories? In reply to
Make sure that you have the tags on separate lines. If you have tags on the same line (without installing the Enhanced Template.pm codes, then the tags will not properly work.

Also, make sure that you have DEFINED numcat tag in the %globals hash in the site_html_templates.pl like the following:

Code:

numcat => &numcat


Regards,

Eliot Lee
Quote Reply
Re: Number of Categories? In reply to
Hi Eliot,

Thanks for the reply. Here is the code from site_html_templates.pl As you can see its per the FAQ. I noticed the formating looks different than other subs in the file but I don't think thats it.

Yes, I have the Enhanced Template Mod installed along with Widgez Subcategories Like Yahoo! Mod.

I only plan to use this Num Mod on my category.html template.
-------code------
# You can put variables here that you would like to use in any
# of your templates.

%globals = (
date => &get_date,
time => &get_time,
db_cgi_url => $db_cgi_url,
build_root_url => $build_root_url,
site_title => $build_site_title,
css => $build_css_url,
numcat => &numcat,
numlinks => &numlinks,
banner => ''
);


sub numlinks {
#------------------------------------------------------------------
# Displays number of links

my $count = 0;
open (DB, "<$db_links_name") or
&cgierr("error in numbercat. unable to open database:$db_links_name.\nReason:
$!");
LINE: while (<DB> ) {
if (!(/^#/) && !(/^\s*$/)) {
$line = $_;
chomp ($line);
@fields = &split_decode ($line);
++$count;
}
}
close DB;
return $count;
}

sub numcat {
#------------------------------------------------------------------
# Displays number of categories

my $count = 0;
open (DB, "<$db_category_name") or
&cgierr("error in numbercat. unable to open database:$db_category_name.\nReason:
$!");
LINE: while (<DB> ) {
if (!(/^#/) && !(/^\s*$/)) {
$line = $_;
chomp ($line);
@fields = &split_decode ($line);
++$count;
}
}
close DB;
return $count;
}

Quote Reply
Re: Number of Categories? In reply to
Two possibilities:

1) Take out the <%numcat%> out of the if codes and see if that works.

2) You have a space in your <Ętegory%> tag.

Regards,

Eliot Lee
Quote Reply
Re: Number of Categories? In reply to
I put the space there on purpose because of this new forun software. I did as you suggested and moved the tag out of the IF statements. Didn't work.

Not sure if this is related. When I look at the page source from my browser I see the <if meta_keywords%> tag was still there. So I check the homepage and its fine.



Quote Reply
Re: Number of Categories? In reply to
In Reply To:
Not sure if this is related. When I look at the page source from my browser I see the <if meta_keywords%> tag was still there. So I check the homepage and its fine.
Could be...

Although if you are receiving Unknown Tag: numcat, then that is not the problem.

Regards,

Eliot Lee
Quote Reply
Re: Number of Categories? In reply to
I see what you mean. The Unkown Tag: numcat is returned from the script. Any other suggestions?

Quote Reply
Re: Number of Categories? In reply to
Nope...unless you neglected to upload your edited site_html_templates.pl to your web server BECAUSE this code hack has WORKED for MANY other LINKS users.

Wink

Regards,

Eliot Lee
Quote Reply
Re: Number of Categories? In reply to
Oh man, I can't believe I pulled such a stupied a** move.

Now thats its working, I noticed <%numcat%> and <%numlinks%> returns the grand totals of the db. Is there a code hack for subtotals. In other words, the number of links or subcatgories for that page?

This is it for tonight, I'm going to turn my brain off and watch TV. Sorry dude you had to endure my stupidity.

Thanks for your help!

Quote Reply
Re: Number of Categories? In reply to
In Reply To:
Is there a code hack for subtotals.
Not at this time...may be when I have time, I will come up with something.

In Reply To:
Sorry dude you had to endure my stupidity.
No problem...for those people that do not understand Perl or semantics of the FAQ/Tutorials I write...I will add some additional semantic markers (i.e., explicit descriptions, like TOTAL NUMBER OF CATEGORIES) WHEN I have time.

Tongue

Regards,

Eliot Lee