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

Get category linked as global

Quote Reply
Get category linked as global
Weird it seems you aren't given the category in the link.html template

What global can I use to get the linked category, something like get_category($ID)

?
Quote Reply
Re: [kzap] Get category linked as global In reply to
Create a new global... called link_cat, with the following codes;

Code:
sub {

my $ID = $_[0];
my ($CatID,$CatName);

my $sth = $DB->table('CatLinks')->select( { LinkID => $ID } );
while (my $hit = $sth->fetchrow_hashref) {
$CatID = $hit->{CategoryID};
}

my $sth = $DB->table('Category')->select( { ID => $CatID } );
while (my $hit = $sth->fetchrow_hashref) {
$CatName = $hit->{Full_Name};
}

$CatName ? return $CatName : return;
}

Call this with: <%link_cat($ID)%>

Untested, but it should work.

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: Sep 26, 2003, 1:39 AM
Quote Reply
Re: [Andy] Get category linked as global In reply to
hmm it won't compile, shouldnt there be a shift in there somewhere? I'm not sure...
Quote Reply
Re: [kzap] Get category linked as global In reply to
Nah, $_[0] is the equivelant of a shift(just a habit I have gotten into, as you can assign variables in any order you want, rather than having to assign them in the order they are passed to the sub).

I've updated the code in the above post. Missed out the $DB reference, which is why it was giving you a compile error. Serves me right for doing it at 8am...Laugh

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] Get category linked as global In reply to
oh ok.

Its working.

Thanks once again Andy :)
Quote Reply
Re: [Andy] Get category linked as global In reply to
In Reply To:
Create a new global... called link_cat, with the following codes;

Code:

Call this with: <%link_cat($ID)%>
Does this mean I replace $ID withteh category ID when calling ccunet
my Christian web
Quote Reply
Re: [ccunet] Get category linked as global In reply to
No. This global is for use in detailed.html, or link.html.. where you have the link ID ($ID), and you want to find out the name of the category that the link is in :)

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!