Gossamer Forum
Quote Reply
Clean Title
I use this global to insert to the space in the Title the sign "-"
So if the Title is "aaa bbb ccc" Title I will get aaa-bbb-ccc
If I have title like this one "aaa- "bbb" c'cc" I want it to be 111-bbb-ccc

How can I insert list of character that the global will clean when create the CleanTitle,
Like ")(-+\><}{][,/.

sub {
my $in = $_[0];
my @cut = split /\n/, $in;
my @got;

# pass in as "name"
# eg FooBar|IN
foreach (@cut) {
chomp;
s/\r//g;
s/\f//g;
my $name = $_;
#$link = $CFG->{build_root_url}.qq{/search/$name};
my $hash;
$hash->{Title} = $_;
$hash->{CleanTitle} = $_;
$hash->{CleanTitle} =~ s/ /-/sig;
push @got, $hash;
}
return { format_page_loop => \@got };
}
Quote Reply
Re: [nir] Clean Title In reply to
Hi,

Just before:

Code:
$hash->{Title} = $_;
$hash->{CleanTitle} = $_;

..try adding this line:

Code:
$hash->{CleanTitle} =~ s/[")(-\+\><}{\]\[,\/\.]//g;


Untested, but should work.

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: [Andy] Clean Title In reply to
Thanks,
It needs to be like this
sub {
my $in = $_[0];
my @cut = split /\n/, $in;
my @got;

# pass in as "name"
# eg FooBar|IN
foreach (@cut) {
chomp;
s/\r//g;
s/\f//g;
s/[")(-\+!:@#^&_|\><}{\]\[,'\/\.]//g;
my $name = $_;
#$link = $CFG->{build_root_url}.qq{/search/$name};
my $hash;

$hash->{Title} = $_;
$hash->{CleanTitle} = $_;
$hash->{CleanTitle} =~ s/ /-/sig;
push @got, $hash;
}
return { format_page_loop => \@got };
}

But there is a strange thing that if a word start with Big latter it create double -
Like this
"aaa Bbb ccc" it will look like this aaa--Bbb-ccc
Any idea
Quote Reply
Re: [nir] Clean Title In reply to
What is the example data passed in? I think this global could be cleaned up a bit ;)

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: [Andy] Clean Title In reply to
Accell UltraRun B068C
Accell-UltraRun--B068C

Watt 2.1 Bluetooth
Watt--21-Bluetooth

Audiovox XMC10A
Audiovox---XMC10A
Quote Reply
Re: [nir] Clean Title In reply to
Try this global:

Code:
sub {
my @loop;

foreach (split /\n/, $_[0]) {
s/[)(-\+!:@#^&_|\><}{\]\[,'\/\.]//g;
my $hash;
$hash->{Title} = $_;
$hash->{CleanTitle} = $_;
$hash->{CleanTitle} =~ s/\s+/-/g;
$hash->{CleanTitle} =~ s/\-+/-/g;
push @loop, $hash;
}

return { format_page_loop => \@loop };

}

Call it in the same way as you were with the other global.

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!

Last edited by:

Andy: Aug 20, 2009, 2:42 AM
Quote Reply
Re: [Andy] Clean Title In reply to
Yes it work:)
There is small thing if in the Title there is something like
Audiovox - XMC10A
It create
Audiovox---XMC10A
Is there a way to solve this too that it will be
Audiovox-XMC10A
Quote Reply
Re: [nir] Clean Title In reply to
Hi,

Try the modified version - should get rid of the --, --- etc bits for ya =)

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: [Andy] Clean Title In reply to
ThanksSmile
Quote Reply
Re: [Andy] Clean Title In reply to
I use this globale for clean Title
sub { my @loop; foreach (split /\n/, $_[0]) { s/[)(-\+!:@#%^&_|"\><}{\]?\[,\/\.]//g; my $hash; $hash->{Title} = $_; $hash->{CleanTitle} = $_; $hash->{CleanTitle} =~ s/\s+/-/g; $hash->{CleanTitle} =~ s/\-+/-/g; push @loop, $hash; } return { format_page_loop => \@loop }; }

I have small problem with Title that when I have somting like this aaa/bbb
who can I get aaa-bbb now it delete the / and create aaabbb
Quote Reply
Re: [nir] Clean Title In reply to
So whats the problem? Stuff like:

aaa/bbb

..is being converted to:

aaabbb

...but you want it to be:

aaa-bbb

?

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: [Andy] Clean Title In reply to
Yes,I want it to be: aaa-bbb
Quote Reply
Re: [nir] Clean Title In reply to
Try changing:

s/[)(-\+!:@#%^&_|"\><}{\]?\[,\/\.]//g;

to

s/[)(\+!:@#%^&_|"\><}{\]?\[,\/\.]//g;

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: [Andy] Clean Title In reply to
Thanks,
It delete the / but not create the - so I get aaabbb
Quote Reply
Re: [nir] Clean Title In reply to
Ah sorry, should be:

Code:
s/[)(\+!:@#%^&_|"\><}{\]?\[,\.]//g;

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!