Gossamer Forum
Home : Products : Links 2.0 : Customization :

How to show # categories ?

Quote Reply
How to show # categories ?
Hello,


Anybody know how to show number of categories such as number of links? Thank you in advance.


Kay
Quote Reply
Re: How to show # categories ? In reply to
do you mean number of categories in your database? or the number of sub categories in a single category? I did the second one at my site

------------------
LookHard Search
lookhard.hypermart.net
Lavon Russell
Quote Reply
Re: How to show # categories ? In reply to
Hi Lavon,


Thanks for responding. I mean the number of categories in the database. But the number of sub cat in a single cat also sounds pretty cool. May i know the way to do that, please? Thank you.


Regards,
Kay
Quote Reply
Re: How to show # categories ? In reply to
Ok, i think to get the number of all cats, you just have to open the database and then print it into a scalar, something like
open (CAT, "<$db_category_id_file_name");
print CAT $catnum;
close CAT;
and then put catnum => $catnum, in site_html_templates.pl. I tried this but its not working so i'll look at it later.
-----------------------
I got the categories in a cat like this, in nph-build.cgi go to sub build_category_pages
find
Code:
$title_linked = &build_linked_title ($cat);
$title = &build_unlinked_title ($cat);
$total = ($#{$links{$cat}} + 1) / ($#db_cols + 1);
$category_name = $cat;
$category_name_escaped = &urlencode ($cat);
$category_clean = &build_clean ($cat);
and change it to this
Code:
$title_linked = &build_linked_title ($cat);
$title = &build_unlinked_title ($cat);
$total = ($#{$links{$cat}} + 1) / ($#db_cols + 1);
$category_name = $cat;
$category_name_escaped = &urlencode ($cat);
$category_clean = &build_clean ($cat);
$subnum = ($#{$subcategories{$cat}} + 1);

Then in site_html_templates.pl, go to sub site_html_category
and put subnum => $subnum, in it. Then wherever you want it to show how many categories are in the category your in.


------------------
LookHard Search
lookhard.hypermart.net
Lavon Russell
Quote Reply
Re: How to show # categories ? In reply to
Bmxer,

Nice try with trying to use the $db_category_id_file_name. But this will not work because that file contains the last Category ID number, which is not the same for the total number of categories in the categories.db file.

For example, I have 401 in the $db_category_id_file_name file, but I only have 394 Categories in the categories.db file due to deletion of categories.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------



Quote Reply
Re: How to show # categories ? In reply to
Thanks a lot for your suggestions, Lavon and Eliot. Do you have any better solution about the issue above, Eliot? I really hope you have.


Regards,
Kay


[This message has been edited by Kay (edited January 06, 2000).]
Quote Reply
Re: How to show # categories ? In reply to
Did anyone ever figure this out?
Quote Reply
Re: [lordmouse] How to show # categories ? In reply to
Just in case if anyone needs it, here is a global that I am using to count number of subcategories in any given category.

sub {
# GLOBAL NAME: Count_Subcategories
# PURPOSE: Count the number of sub-categories within a given category.
# CALL TAG: <%Count_Subcategories($ID)%>

my $category_id = shift; # Get the category ID passed to the global

# Ensure the category ID is provided
return 0 unless $category_id;

# Access the Category table
my $category_table = $DB->table('Category');

# Count sub-categories
my $subcategory_count = $category_table->count({ FatherID => $category_id });

return $subcategory_count; # Return just the count
}

Vishal
-------------------------------------------------------
Quote Reply
Re: [VishalT] How to show # categories ? In reply to
You are in the Links2 forum - not LinksSQL/GossamerLinks ;)

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] How to show # categories ? In reply to
Andy,

Oops.. Sorry about that.. and thank you for correcting me.. appreciate it :).

Vishal

Vishal
-------------------------------------------------------