Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Finding Category with Link ID?

Quote Reply
Finding Category with Link ID?
Hi,

Can anyone tell me if there is a standard tag that can be used to get the "category" and its URL, of a link if I have the Link ID?

As an example, if I used it on a detailed page, what I want to do is provide a link back to the category the link is in (although I'm not using it on a detailed page).

I have tried <%GT::Template::dump%> but there doesn't seem to be on in there.

Thanks,
Regan.

Last edited by:

ryel01: Sep 10, 2001, 5:24 PM
Quote Reply
Re: [ryel01] Finding Category with Link ID? In reply to
Hi,

This isn't available as the link could be in one or more categories. You could do this with a global though:

get_category_url =>
Code:
sub {
my $tags = shift;
my $catlink_db = $DB->table ('CatLinks', 'Category');
my $sth = $catlink_db->select ( ['Full_Name'], { LinkID => $tags->{ID} });
my ($full_name) = $sth->fetchrow_array;
my $cat_db = $DB->table('Category');
my $url = $cat_db->as_url ($full_name);
return $url;
}
Untested, but looks like it should work.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Finding Category with Link ID? In reply to
This code would return the first occurance of the Link/category, or "the" category if the link was only in one category.

You'd need to iterate the returned hash of values, convert the full name to the url code, push this onto an array, and return the array reference for the <%loop%> variable to use.

I'd offer up some code, but I don't see the point of putting more untested code on top of untested code <G> But, it would be just a modification of a line or two of the codes above to add the iterator and the push.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.