Gossamer Forum
Home : Products : Gossamer Links : Version 1.x :

Category names.

Quote Reply
Category names.
I have a site with a category hierarchy such as:

Top : Automotive : Maintenance & Repair : Repair Shops

I would like to be able to use "Repair Shops" as part of the page title and as a separate title within the page. I think there might already be a mod for this or a variable I have not found. Can anyone point me in the right direction?? Thank You.

Quote Reply
Re: Category names. In reply to
If you want Repair Shops by itself, just use <%category_name%>.



<><------------><>
Daniel
http://www.christian-search.net
<><------------><>
Quote Reply
Re: Category names. In reply to
Daniel,
<%category_name%> returns the fully qualified category name.

ie.: Automotive/Maintenance & Repair/Repair Shops

Thanks for the suggestion.

Quote Reply
Re: Category names. In reply to
I just did something similar, except it was on the output of related. See this link:
http://www.gossamer-threads.com/...w=collapsed&sb=5

What you'll want to do is go into page.cgi &/or nph-build.cgi and in sub build_category_page you can grab the value of $category_name as Daniel suggested and then run it through the parse mentioned in the above link though I would assign it something like (short_cat_name) amd once you have it formated the way you want it pass it to:
$OUT{short_cat_name} = $tempvar;
Then you should be able to access this new value in your templates, by using <%short_cat_name%> note if you have both static and dynamic site you'll need to change both page.cgi & nph-build.cgi, it's a little more complex to do it in nph-build but it's still pretty straight forward...

a quick example would be:

my @short_cat_name = split(/\//,$OUT{'category_name'});
my $short_name = $short_cat_name[$#{short_cat_name}];
$OUT{short_cname} = $short_name;

You could place this code somewhere right after values of %OUT are filled in, I think this piece may work as a cut and paste but EDITED has been tested and works like a charm...have fun.

Quote Reply
Re: Category names. In reply to
Try using <%description%> (although this will only work if you have the actual NAME of the category in the Category Description field, as opposed to a description of the category contents.)

I also use a modified build_linked_title to 'chop' off the current category so I can use the <%description%> somewhere else on the page and format it differently to the linked category tree:


sub build_linked_title_cat {
# --------------------------------------------------------
# Returns a string of the current category broken up by section,
# with each part linked to the respective section, only this
# version chops off the last category name so you can use
# 'description' for the current category elsewhere on the page.

my $input = shift;
my (@dirs, $dir, $output, $path, $last);

@dirs = split (/\//, $input);
$last = pop @dirs;
$output = qq| <A HREF="$LINKS{build_root_url}/">Home</A> > |;
for (0 .. $#dirs) {
$path = "/" . &build_clean_name( join "/", @dirs[0 .. $_] );
$output .= qq| <A HREF="$LINKS{build_root_url}$path/">$dirs[$_]</A> >|;
}
$output .= "";
return $output;
}


Hope this helps.

All the best
Shaun