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

category information available on links detail page?

Quote Reply
category information available on links detail page?
I could find no global on a links detail page that would give a cross-reference to the category under which the link is located. The only thing I could think of is to parse the <%title%> tag which contains the category in it. Is there a more direct way to get the 'first level' up category associated with a link on this page?
Quote Reply
Re: [scorpioncapital] category information available on links detail page? In reply to
Something like this should work;

Code:
sub {

my $ID = shift;
my (@_ids,@cat_titles);

my $table = $DB->table('CatLinks');
my $sth = $table->select( { LinkID => $ID } );

while (my $hit = $sth->fetchrow_hashref) {
push(@_ids,$hit->{CategoryID});
}

foreach (@_ids) {
my $table = $DB->table('Category');
my $sth = $table->select( { ID => $_ } );

while (my $hit = $sth->fetchrow_hashref) {
push(@cat_titles,$hit->{Title});
}

}

return join(", ",@cat_titles);

}

Call it with something like;

<%global_name($ID)%>

Untested, but the theory is beind it (if it doesn't 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!
Quote Reply
Re: [Andy] category information available on links detail page? In reply to
Cool, I did it the lazy way for now :)

sub {
# gets the category of this link on the link detail page by parsing the title variable

my $title = shift;
my @fields = split(/:/, $title);
my $cat = @fields[1];
for ($cat) {
s/^\s+//;
s/\s+$//;
}
return $cat;
}
Quote Reply
Re: [scorpioncapital] category information available on links detail page? In reply to
Not sure how that is meant to work.. but if it does, then by all means, use it Smile

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] category information available on links detail page? In reply to
The <%title%> global is available on each link page. Take a look at it, it is a concatenation of the category (e.g. TopLevel:SecondLevel:thirdlevel)

So this just splits that string into an array, cleans it up for whitespaces, and then gets what you want
Quote Reply
Re: [scorpioncapital] category information available on links detail page? In reply to
If my global works, I would recommend using that. Your global will not work with multiple categories assigned to a link. My one should do that just fine :)

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!