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

Displaying category 'Name' on detailed pages? >>

Quote Reply
Displaying category 'Name' on detailed pages? >>
Hello,

I've been stuck trying to work out a global to display a categories unlinked top-level 'Name' on my detailed pages. There don't seem to be any tags available on the detailed pages which would display the categories 'Name' ONLY. Looks like LinksSQL is missing the hardcode to return <%Name%> properly. Using the <%Full_Name%> tag does work, but I get something like this...

Cars : Intake : HKS

What I need returned by a global is only:

Cars (Unlinked)

I've tried working out a global to split 'Full_Name' but haven't had much luck. Any help would be greatly appriciated!!!

Thanks
Quote Reply
Re: [Jonze] Displaying category 'Name' on detailed pages? >> In reply to
This should work:

sub {
my $tags = shift;
my $id = $tags->{'ID'};
my $db = $DB->table ('Category','CatLinks');
$db->select_options('LIMIT 1');
my $catid = $db->select ( { LinkID => $id }, ['Name'] )->fetchrow_array;
return $catid;
}
Quote Reply
Re: [afinlr] Displaying category 'Name' on detailed pages? >> In reply to
Thanks so much for the help! =) That helped me out big time.

I had to make a few changes so the global would only select from the top level category. For others who may be interested, here's the best solution I could come up with...

sub {
my $tags = shift;
my $id = $tags->{'ID'};
my $db = $DB->table ('Category','CatLinks');
$db->select_options('ORDER BY ID ASC', 'LIMIT 1');
my $catid = $db->select ( { LinkID => $id , FatherID => 0 }, ['Name'] )->fetchrow_array;
return $catid;
}

One problem I'm still having is related to the fact that the <%title_linked%> tag returns a somewhat random category to be displayed when placing links in multiple categories. Because of this the top category returned for this new global, and the one displayed for <%title_linked%> sometimes differ.

Has anyone figured out how Links chooses the father category for use in the <%title_linked%> tag??? By looking at build.pm the only idea I can come up with is that the system picks the second category the link was placed in.

Thanks again Smile
Quote Reply
Re: [Jonze] Displaying category 'Name' on detailed pages? >> In reply to
I think its the last category in the CatLinks table for that Link - there is a post somewhere in the forum where someone investigated this.
Quote Reply
Re: [afinlr] Displaying category 'Name' on detailed pages? >> In reply to
Well, I really wish it picking either the first or last from that table. I've just did some more investigating myself and here's what I saw...

For some reason the <%title_linked%> tag is pulling the 2nd from the last category in the CatLinks table. Most of my Links are in three different categories and seems to always show that 2nd category through <%title_linked%>.

I've did tons of searches trying to find my answer, but all I found were people wondering the same thing with no answers. I don't know... My heads spinning. Crazy

Thanks very much for your help though!