Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Any variable for number of sub-cats?

Quote Reply
Any variable for number of sub-cats?
I wanted to know if there is a variable I can call from a category page that returns the number of sub categories. I want to use it to "personalize and quantify" the title, thus:

XXX XDirector<%~if subcat > 1%>ies<%else%>y<%endif%>:

Thanks!
dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [carfac] Any variable for number of sub-cats? In reply to
So you wanna get the number of categories that are directly in the category the person is in?

For example:

Something/Bla
Something/Bla/Whatever
Something/Bla/Whatever/Something else
Something/Bla/Whatever2
Something/Bla/Whatever2/Whatever
Something/Bla/Whatever3

..in "Something/Bla" would return 3 (as there are 3 categories that are linked to it)

If so, this simple global should do the trick:

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

...then call with:

Code:
<%see_how_many_sub_cats($ID)%>

Hope that helps.

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] Any variable for number of sub-cats? In reply to
Andy-

As always, perfect, and thank you!
dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [carfac] Any variable for number of sub-cats? In reply to
Whoops- does NOT quite work. ($ID) does return the correct Categoryt ID number (I checked it), but the global returns the total number of categorys, not the number with a FatherID = ID....

So, somehow $ID is not getting into that global....
dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [carfac] Any variable for number of sub-cats? In reply to
The correct variable might be $CategoryID

Adrian
Quote Reply
Re: [carfac] Any variable for number of sub-cats? In reply to
This in category.html, or detailed.html ?

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] Any variable for number of sub-cats? In reply to
Sorry- it is called from a Category.html page.

I called <%set variable = $ID%> and variable is the correct Category ID.... but the global returns (on any category.html, for any category) 6,384, whic\h is the sum total of ALL categorys... not just those with $ID as FatherID
dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [carfac] Any variable for number of sub-cats? In reply to
MMm, try adding some debugging to the global:

Code:
sub {
print qq| { FatherID => $_[0] }|;
return $DB->table('Category')->count( { FatherID => $_[0] } ) || 0;
}

..and see what that prints out.

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] Any variable for number of sub-cats? In reply to
At the top of the page:

{ FatherID => 2108 } { FatherID => HASH(0x808dc9690) }

Where I called the code: 10

10 is NOT correct, in this instance, it should be 2

Here is the test page:

http://www.bcdb.com/bcdb/page.cgi?g=Other_Studios/D/DNA_Productions/

the code is called right after: "<meta name="keywords" content="
dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [carfac] Any variable for number of sub-cats? In reply to
Are you calling it 2 times? Cos you should only see:

{ FatherID => 2108 }

..not:

{ FatherID => 2108 } { FatherID => HASH(0x808dc9690) }

Also, whats the EXACT template code you are using?

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] Any variable for number of sub-cats? In reply to
OH- found the problem... (and yes, I am an ijut!)

I was using <%set cat_num = sub_cats_num($ID)%> and then calling <%cat_num%> ... did not realize cat_num was used!

I changed to <%set num_o_cats = sub_cats_num($ID)%> and it works!
dave

Big Cartoon DataBase
Big Comic Book DataBase

Last edited by:

carfac: Jun 13, 2010, 10:54 AM
Quote Reply
Re: [carfac] Any variable for number of sub-cats? In reply to
Haha cool :)

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] Any variable for number of sub-cats? In reply to
Thanks for laughing.... I feel like a dork for not catching that... :)
dave

Big Cartoon DataBase
Big Comic Book DataBase

Last edited by:

carfac: Jun 13, 2010, 12:20 PM
Quote Reply
Re: [carfac] Any variable for number of sub-cats? In reply to
Trust me, I've done more than my fair share of silly mistakes ;)

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates