Gossamer Forum
Home : Products : Links 2.0 : Customization :

Mod: show last category name on a page

Quote Reply
Mod: show last category name on a page
Someone asked how to do this, so after a bit of fiddlin', I got it. What it does is, instead of having this (title-linked):

Top : Testing Two : Testing Two Sub : Testing Two Sub Sub

...you can have this (last_cat):

Testing Two Sub Sub

This is so done you can put the last subcat name on the page as a title.

====

Open nph-build.cgi, find sub build_category_pages, and about in the middle of the routine find this code and add the red:

$title_linked = &build_linked_title
($cat);
$last_cat = &build_last_cat ($cat);
$title = &build_unlinked_title ($cat);
$total = ($#{$links{$cat}} + 1) / ($#db_cols + 1);
$category_name = $cat;
$category_name_escaped = &urlencode ($cat);
$category_clean = &build_clean ($cat);

====

Still in nph-build.cgi, add this sub at the end of the file (after sub build_check_dir), but above the 1;

sub build_last_cat {
# --------------------------------------------------------
# Returns the last cat from a string of the current category.


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

@dirs = split (/\//, $input);
$last = &build_clean(pop @dirs);

$output = qq|$last|;

return $output;
}


====

Now open site_html_templates.pl, and in sub site_html_category add the red:

category_name => $category_name,
category_name_escaped => $category_name_escaped,
last_cat => $last_cat,
category_clean => $category_clean,

====

Then, in your category.html template, add this where you want the category name to appear:

<%last_cat%>

You can format it's appearance by putting HTML or CSS around it:

<font size="3"><b><%last_cat%></b></font>


That's all! Hope you find this useful... Cool


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] Mod: show last category name on a page In reply to
You rock my world!! I been working on this ALL afternoon and now I have 100% working as I wanted!!

Thank you for your time!!


Best Regards.

Danny de Hek
Managing Director

New Zealand's Information Network - Scanning the nation for YOUR information

Phone: +64 3 312 5456 Fax: +64 3 312 5458

*Important* Please include all previous correspondence in your replies