Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

Number of links in one category

Quote Reply
Number of links in one category
Hi Andy,
I just want to print the number of links in one subcategory.
I tried it with Ultraglobals, but had no sucess :-(
Code:
<%Plugins::ULTRAGlobals::Get_Totals('Links','$678')%>


Do you have any suggestions?
Thanks

Matthias
gpaed.de

Last edited by:

Matthias70: Mar 11, 2011, 11:48 AM
Quote Reply
Re: [Matthias70] Number of links in one category In reply to
Hi,l

So literally just grab the number of links in a given sub-category?

There are a couple of ways of doing this...

1) Add the new global: get_subcat_count

Code:
sub {
return $DB->table('CatLinks')->count( { CategoryID => $_[0] } ) || 0;
}

...call with:

<%get_subcat_count(1234)%> (1234 = the category ID you wanna get)

2) Use the existing field in the Category table:

get_subcat_count

Code:
sub {
return $DB->table('Category')->select( ['Direct_Links'], { ID => $_[0] } )->fetchrow;
}

Untested, but both of those should do the trick (the 2nd one is probably the better option, seeing as GLinks has already been so nice to give you that value <G>)

Cheers

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!

Last edited by:

Andy: Mar 12, 2011, 3:13 AM
Quote Reply
Re: [Andy] Number of links in one category In reply to
Hi Andy,
do I have to call the second solution with
Code:
<%get_subcat_count(678)%>

Cause I get an error called
Code:
Can't call method "fetchrow" on an undefined value at (eval 42) line 2.
Thanks

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] Number of links in one category In reply to
Hi,

Sorry, please try the modified 2nd global above. I had "CatLinks" instead of "Category" in there Wink Serves me right coding it at 7:30 in the morning <G>

Cheers

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] Number of links in one category In reply to
O.K. now the second solution works
But it does not count the links in the subcats Frown
Thanks

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] Number of links in one category In reply to
Quote:
But it does not count the links in the subcats Frown

You didn't say you wanted the number in sub-categories too ;)

Thats a simple change

Just replace:

Code:
Direct_Links

...to:

Code:
Number_of_Links

..in the global

Wink

Cheers

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] Number of links in one category In reply to
Thanks Andy,
works perfect Smile

Matthias
gpaed.de