Gossamer Forum
Home : Products : Gossamer Links : Version 1.x :

How to display a total amount of categories?

Quote Reply
How to display a total amount of categories?
Hi,

i know that there's a hack for Links 2.0 to display the total amount of categories - does this exist for Links SQL too?

Thanks for hints.

Quote Reply
Re: How to display a total amount of categories? In reply to
Yes...it does...and the codes have been posted in some Threads recently....

Here it goes again...

1) Add the following codes:

Code:

&get_totalcats


in the @EXPORT array section at the top of the DB_Utils.pm file.

2) Add the following sub to your DB_Utils.pm file:

Code:

sub get_totalcats {
#-----------------------------------------------------
my ($CATDB, $GRAND_TOTAL);
$GRAND_TOTAL = 0;
$CATDB = new Links::DBSQL "$LINKS{admin_root_path}/defs/Category.def";
$GRAND_TOTAL = $CATDB->total();
return $GRAND_TOTAL;
}


3) Then in your HTML_Templates.pm, add the following global variable config:

Code:

totalcats => \&Links::DB_Utils::get_totalcats


4) And to print the total NUMBER of categories, add the following tag in any of your template files:

Code:

<%totalcats%>


Regards,

Eliot Lee