Gossamer Forum
Home : Products : Links 2.0 : Customization :

Change & to & in link names...

Quote Reply
Change & to & in link names...
 
How to I go about changing "&" to "&" in link names when a link is added or modified. I can find info on how to do this with category names, but not with link names. As an alternative to do it at he adding or modification stage, I could do it when I display the link. Either way, I'm at a loss as to where to insert my code

The code I'm thinking I need to use is...

$input =~ s,&,&,g; # Change '&' to '&'

...is this right and where should it go?

m.
Quote Reply
Re: [Moby] Change & to & in link names... In reply to
A slow response, but here it is:

In the sub build_category_pages in nph-build.cgi

# Otherwise we either only have less then x number of links, or we are not
# splitting pages, so let's just build them all.
else {
for ($i = 0; $i < $numlinks; $i++) {
%tmp = &array_to_hash ($i, @{$links{$cat}});
$links .= &site_html_link (%tmp);
$links =~ s/&/&#38;/g; #change '&' to '&#38;'
}
}

# Create the main page.

This is much better than using search-and-replace on the links.db like I did before!


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] Change & to &amp; in link names... In reply to
Thanks, i'll give it a whirl!

m. ;)
Quote Reply
Re: [Moby] Change & to &amp; in link names... In reply to
Hmm, that code worked at first, but later I noticed that it didn't... Unimpressed

A bit more experimenting brought me to adding this to sub site_html_link in site_html_templates.pl, under my %rec = @_;


if ($rec{'Title'}) { ($rec{'Title'}) =~ s/&/&#38;/g; }
if ($rec{'Description'}) { ($rec{'Description'}) =~ s/&/&#38;/g; }


Remove the code I posted before.

Works fer me! Smile


Leonard
aka PerlFlunkie