Gossamer Forum
Home : Products : Links 2.0 : Customization :

$category_clean mod

Quote Reply
$category_clean mod
Hi,

I know $category_clean will give you the complete category, including it's parent category

(So, Articles/Modelling category becomes Articles : Modelling)

I am trying to find how to get just the current category without it's parent categories or child categories,

so Articles/Modelling will give just 'Modelling' - no HTML, no '/', no '_', etc.

Can anyone help on this?

Many thanks,
Andy

------------------
Quote Reply
Re: $category_clean mod In reply to
in (nph-build.cgi) find:
sub build_linked_title

play with it to get the desired output.

i just wanted to replace the : with /
Quote Reply
Re: $category_clean mod In reply to
what i did, was put in a meta description for each category... so if you had a category:
articles/modelling, put "modelling" in as the meta description, and call that with <%meta_name%> in the template.

warning: this mod is untested and i just made it up.. there may be bugs, or it might not work... but, theoretically, this should work.
in the build_category_pages sub in nph-build.pl:

replace this: my ($cat, $url, $dir, @related, $relation, $page_num, $next_page, $numlinks);

with this: my ($cat, $url, $dir, @related, $relation, $page_num, $next_page, $numlinks, @category_name_clean);

and further down, under
$category_name_escaped = &urlencode ($cat);
$category_clean = &build_clean ($cat);

paste this:
@category_name_clean = split(///, $category_clean);
$category_clean = @category_name_clean[$#category_name_clean];


hope that helps (works)
--Tom
Quote Reply
Re: $category_clean mod In reply to
You can use <%category_name%>

But it will have the '_' in it, but if it's highlighted, you won't see it.

You could also pass $category_name through an regex $category_name =~ s/_/ / in the nph_build routine 'sub build_category_pages' about 30-40 lines down where it says:


Code:
$title_linked = &build_linked_title ($cat);
$title = &build_unlinked_title ($cat);
$total = ($#{$links{$cat}} + 1) / ($#db_cols + 1);
$category_name = $cat;
$category_name =~ s/_/ /g;
$category_name_escaped = &urlencode ($cat);
$category_clean = &build_clean ($cat);
Quote Reply
Re: $category_clean mod In reply to
Pugdog/Garadon,

Thanks for the ideas - I'll go for the latter one, as it saves having to re-define the database and adding data to categories already created.

Thanks again,
Andy

------------------
Quote Reply
Re: [pugdog] $category_clean mod In reply to
OK I added

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

It was

$title_linked = &build_linked_title ($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_category ($cat);

When I display

<%$category_clean%>

Tag Unknow or displays the long name like Accommodation - Apartments - Ashburton when I would love it to be just Ashburton

Not the best at doing code editing but would be very happy if anyone anyone can give me a hand ;-)


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