Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Category tag in link.html?

Quote Reply
Category tag in link.html?
I'd like to call the link's category in link.html.

However, when I use <%Category%>, I get "Unknown Tag: 'Category'".

Any ideas?
Quote Reply
Re: [Jobu] Category tag in link.html? In reply to
Anyone? :)
Quote Reply
Re: [Jobu] Category tag in link.html? In reply to
Unless you have created one, there shouldn't be one. You can use <%GT::Template::dump%> to see what you do have. Otherwise, you can easily create a global like:

http://www.gossamer-threads.com/...i?post=196185#196185

Hope this helps,


- Jonathan
Quote Reply
Re: [jdgamble] Category tag in link.html? In reply to
In Reply To:
Unless you have created one, there shouldn't be one. You can use <%GT::Template::dump%> to see what you do have. Otherwise, you can easily create a global like:

http://www.gossamer-threads.com/...i?post=196185#196185

Hope this helps,


Thanks. I did the Dump, and you are right, there is no Category variable available. Are you able to expound upon the global code to achieve what I want? I tried Alex' global at the end of the thread you suggested, and just got a linked "Home :" return.

Ideally, I could get a linked or unlinked (it doesn't matter) "Category > Subcategory > Subsubcategory" return for the applicable link.
Quote Reply
Re: [Jobu] Category tag in link.html? In reply to
Try this:

Code:

sub {
my $tags = shift;
my $catid = $DB->table('CatLinks')->select('CategoryID', { LinkID => $tags->{ID} })->fetchrow;
my ($full_name) = $DB->table('Category')->select('Full_Name', { ID => $catid })->fetchrow;
require Links::Build;
my $title = Links::Build::build('title_linked', $full_name);
return $title;
}


I haven't tested it, but it should work.

- Jonathan
Quote Reply
Re: [jdgamble] Category tag in link.html? In reply to
In Reply To:
Try this:

Code:

sub {
my $tags = shift;
my $catid = $DB->table('CatLinks')->select('CategoryID', { LinkID => $tags->{ID} })->fetchrow;
my ($full_name) = $DB->table('Category')->select('Full_Name', { ID => $catid })->fetchrow;
require Links::Build;
my $title = Links::Build::build('title_linked', $full_name);
return $title;
}




I haven't tested it, but it should work.



Very good, thank you. This returns a linked string, for example "Home: Category: Subcategory" where Home and Category are linked. Is it possible to:

1. Have " > " be used instead of ": "
2. Either link the whole string (i.e., including "Subcategory") or unlink everything?

Thanks! I owe you a beer!

EDIT: I changed the global to:

Code:
sub {
my $tags = shift;
my $catid = $DB->table('CatLinks')->select('CategoryID', { LinkID => $tags->{ID} })->fetchrow;
my ($full_name) = $DB->table('Category')->select('Full_Name', { ID => $catid })->fetchrow;
return $full_name;
}


And that gives me "Catgegory/Subcategory"

That works fine for me, unless there is an easy way to link all of Home, Category and Subcategory using ">"

Thanks again!

Last edited by:

Jobu: Aug 17, 2006, 3:12 PM
Quote Reply
Re: [Jobu] Category tag in link.html? In reply to
I think you can call format_title from your links.html template (assuming Category is your global name).

<%Links::Utils::format_title($category, separator => $crumb_separator, no_escape_separator => $no_escape_crumb_separator, include_home => 1, link_type => 2)%>

- Jonathan
Quote Reply
Re: [jdgamble] Category tag in link.html? In reply to
In Reply To:
I think you can call format_title from your links.html template (assuming Category is your global name).

<%Links::Utils::format_title($category, separator => $crumb_separator, no_escape_separator => $no_escape_crumb_separator, include_home => 1, link_type => 2)%>


My preference would be to have the display the same as on the New and Cool pages:

Code:

<%Links::Utils::format_title($title_loop, separator => $category_separator, no_escape_separator => $no_escape_category_separator, include_home => 0, link_type => 1)%>



Right now my global is pulling the result "Category/Subcategory". So I guess I need to return whatever the equivalent of $title_loop. Maybe this was what your initial global suggestion did? I will try it out.

EDIT - That didn't work. What is the $title_loop variable referring to in the above? My global should grab that equivalent field.

Last edited by:

Jobu: Aug 17, 2006, 3:43 PM
Quote Reply
Re: [Jobu] Category tag in link.html? In reply to
try something like this:

Code:

sub {
my $tags = shift;
my $catid = $DB->table('CatLinks')->select('CategoryID', { LinkID => $tags->{ID} })->fetchrow;
my ($full_name) = $DB->table('Category')->select('Full_Name', { ID => $catid })->fetchrow;
require Links::Utils;
my @titles = split(/\//, $full_name);
return (Links::Utils::format_title(@titles, separator => ">"));
}


That MIGHT work... (will be back to check in a few hours)...

- Jonathan
Quote Reply
Re: [jdgamble] Category tag in link.html? In reply to
In Reply To:
try something like this:

Code:

sub {
my $tags = shift;
my $catid = $DB->table('CatLinks')->select('CategoryID', { LinkID => $tags->{ID} })->fetchrow;
my ($full_name) = $DB->table('Category')->select('Full_Name', { ID => $catid })->fetchrow;
require Links::Utils;
my @titles = split(/\//, $full_name);
return (Links::Utils::format_title(@titles, separator => ">"));
}



That MIGHT work... (will be back to check in a few hours)...


Unfortunately, I get the following error:

Can't use string ("Distributors & Resellers") as an ARRAY ref while "strict refs" in use at /var/home/xxx/wiredbiz.com/cgi-bin/links/admin/Links/Utils.pm line 492.

"Distributors & Resellers" is one of the main categories in our DB.
Quote Reply
Re: [Jobu] Category tag in link.html? In reply to
Just got home...

This should do the trick:

Code:

sub {
require Links::Utils;
require Links::Build;
my $tags = shift;
my $catid = $DB->table('CatLinks')->select('CategoryID', { LinkID => $tags->{ID} })->fetchrow;
my $full_name = $DB->table('Category')->select('Full_Name', { ID => $catid })->fetchrow;
return (Links::Utils::format_title(Links::Build::build_title($full_name), separator => " > ", link_type => 1, ));
}


Good Luck!

- Jonathan
Quote Reply
Re: [jdgamble] Category tag in link.html? In reply to
In Reply To:
Just got home...

This should do the trick:

Code:

sub {
require Links::Utils;
require Links::Build;
my $tags = shift;
my $catid = $DB->table('CatLinks')->select('CategoryID', { LinkID => $tags->{ID} })->fetchrow;
my $full_name = $DB->table('Category')->select('Full_Name', { ID => $catid })->fetchrow;
return (Links::Utils::format_title(Links::Build::build_title($full_name), separator => " > ", link_type => 1, ));
}



Good Luck!


Awesome! Thank you very much! Exactly what I was looking for.