Gossamer Forum
Home : Products : Gossamer Links : Discussions :

%category_name% Change Format

Quote Reply
%category_name% Change Format
I read an old post about this, but I thought I'd ask to see the best way to do this.

I simply want to replace the "/" in the category title with another character. eg. ":" or "-".

I have the latest version 2.2 links sql.

Anyone know an easy way to do this?

eg.

<title>My_Category/Sub_Folder</title>

I want to look like:

<title>My_Category : Sub_Folder</title>

One more thing. I am a perl idiot so if you have a code example, please be specific. I am a PHP guy at heart.

Last edited by:

mddrew01: Jun 14, 2004, 7:04 PM
Quote Reply
Re: [mddrew01] %category_name% Change Format In reply to
You could try a new global;

<%global_name($title)%>

Code:
sub {
my $in = $_[0];
$in =~ s|\Q/| : |g;
#$in =~ s/_/ /g;
}

This should replace the / with :, and also a space between it. i.e;

<title>My_Category : Sub_Folder</title>

... and if you remove the # comment in that routine, it should also change it to look like;

<title>My Category : Sub Folder</title>

Hope that helps :)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [mddrew01] %category_name% Change Format In reply to
Smile
Thanks Andy Worked great!

For anyone else looking to do this. Here are more detailed instructions

go to Build -> Template Globals

Add a global called Whatever:

Let's say

cat_title_char

add the following code in the description field:

sub {
my $in = shift;
$in =~ s,/, : ,g;
return $in;
}

Then in the category.html template add:

<%cat_title_char($category_name)%>

to your title.

You can change the character to whatever you want in this line:

$in =~ s,/, : ,g;