Gossamer Forum
Quote Reply
Removing <b> in global
Hi, with this global I would like to remove any <b> </b> tags with the description that it returns. Any ideas?

sub {
my (@links,$sth,$link);
my $search_db = $DB->table('Links');
$search_db->select_options ("ORDER BY RAND()","LIMIT $_[0]");
$sth = $search_db->select ( { isValidated => 'Yes', Type => 'Star' });
while (my $link = $sth->fetchrow_hashref()) {
if (length $link->{Description} > 50) {
$link->{Description} = substr($link->{Description}, 0, 500) . '...'; }
$link = Links::SiteHTML::tags('link', $link);
push@links, $link;
}
return {RndLnks=>\@links};
}

--------------------------------
Privacy Software
Quote Reply
Re: [BLOOD] Removing <b> in global In reply to
The bold won't be in the global, it will be in your HTML ( or css ) somewhere. If you can't locate it do this to bypass it:

Code:
</b><%global%><b>

Last edited by:

MJB: May 3, 2006, 12:52 PM
Quote Reply
Re: [MJB] Removing <b> in global In reply to
The bold is in the description as html tags on purpose but I need to strip this out via the global as the global results are for another section of the site.

--------------------------------
Privacy Software

Last edited by:

BLOOD: May 3, 2006, 12:55 PM
Quote Reply
Re: [BLOOD] Removing <b> in global In reply to
I'm not the HTML police but <b> is deprecated in favour of <strong> Wink.

A global to strip out the <strong> tags would look something like this:

Code:
sub {
my $field = $_[0];
$field =~ s/\<strong\>//gi;
$field =~ s/\<\/strong\>//gi;
return $field;
}
Call it with <%strip_strong ($Description)%>. There are probably more efficient ways of writing this global so if anyone can improve on it feel free.
Quote Reply
Re: [aus_dave] Removing <b> in global In reply to
Hey many thanks, I had to code it like this -- it works OK but have no idea if its the best way to achive the goal:

sub {
my (@links,$sth,$link);
my $search_db = $DB->table('Links');
$search_db->select_options ("ORDER BY RAND()","LIMIT $_[0]");
$sth = $search_db->select ( { isValidated => 'Yes', Type => 'Star' });
while (my $link = $sth->fetchrow_hashref()) {
if (length $link->{Description} > 50) {
$link->{Description} = substr($link->{Description}, 0, 500) . '...'; }

$link->{Description} =~ s/\<strong\>//gi;
$link->{Description} =~ s/\<\/strong\>//gi;

$link = Links::SiteHTML::tags('link', $link);
push@links, $link;
}
return {RndLnks=>\@links};
}

--------------------------------
Privacy Software

Last edited by:

BLOOD: May 4, 2006, 2:29 AM