Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Ampersand in URLs

Quote Reply
Ampersand in URLs
After having used Links 2.0 for more than 3 years I'm finally part of the LinksSQL universe. What a quantum leap! Smile

Sorry if I'm asking something obvious, but in Links 2.0 I was able to use '&' (ampersand) in categories, so that the URL output looked as follows:

http://blabla.com/Arts_&_Culture/

I transferred my old DB to a test installation of LinksSQL and cats are outputted like this:

http://blabla.com/Arts__Culture/index.html

For reasons of consistency, is there any method of including the &'s in the cat URL?
Quote Reply
Re: [Thomas.] Ampersand in URLs In reply to
I don't think there is. Its a 'foreign charachter' thing...that means you can use any foreign charachters in the category name, without feare of it screwing up. Basically, anything that isn't a-z, 0-9, gets translated into an _.

Hope that helps; and welcome to the LSQL World Smile (very much doubt you will regret it).

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] Ampersand in URLs In reply to
Thanks Andy, it's not a big issue anyhow.

No regrets so far! Cool
Quote Reply
Re: [Thomas.] Ampersand in URLs In reply to
Wait until you get into plugins....so much easier than hacking loads of codes Smile

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] Ampersand in URLs In reply to
In fact, I'm still overwhelmed... Cool

I already visited your plugin site. Lots of work ahead, lol.
Quote Reply
Re: [Thomas.] Ampersand in URLs In reply to
If you ever need a hand, send me a PM..I'm sure I can help you out Smile If its too complex for me, then you could do like I did, and try the forums. A lot of codes and stuff there that can be very helpful Smile

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] Ampersand in URLs In reply to
Thanks Andy, that's really very kind of you!

So, I'm back into the arcane world of GT plugins... Smile
Quote Reply
Re: [Thomas.] Ampersand in URLs In reply to
What I did, as suggested by Alex, was to edit admin/links/Category.pm and find the section:

Code:
sub _clean {
# -------------------------------------------------------------------
# Cleans up a name.
#
my $name = shift;
$name =~ s/\s/_/g;
$name =~ s/[^\w\d_\-\/]/_/g;
return $name;
}

Comment out:

Code:
$name =~ s/[^\w\d_\-\/]/_/g;

so that is looks like:

Code:
sub _clean {
# -------------------------------------------------------------------
# Cleans up a name.
#
my $name = shift;
$name =~ s/\s/_/g;
# $name =~ s/[^\w\d_\-\/]/_/g;
return $name;
}

This will still change the spaces to _ but not the special characters. Just be careful when naming categories with odd characters because it might cause a problem. I've had good luck with it so far. Most characters escape themselves properly via the browser so they're not a problem.

Sean
Quote Reply
Re: [SeanP] Ampersand in URLs In reply to
Hi Sean, thanks a lot. I applied your hack, but I also had to modify the sub _valid_dir routine in nph-build.cgi:

I replaced

if ($dir !~ m,^([\w\/\-]+)$,) {

with

if ($dir !~ m,^([\w\/\-\&]+)$,) {

Now it works perfectly.
Quote Reply
Re: [Thomas.] Ampersand in URLs In reply to
Good catch. I'm running in dynamic mode, so I didn't notice that. Cool

Sean
Quote Reply
Re: [SeanP] Ampersand in URLs In reply to
I apologise for digging up such an old thread, but I have just discovered that GLinks 3.3.0 apparently does not allow foreign characters in category names. It's basically the ampersand issue outlined above.

Also, nph-build.cgi does not have the valid_dir subroutines anymore. Which files would I have to alter in order to get ampersands in categories working?

Thank a lot! Smile
Quote Reply
Re: [Thomas.] Ampersand in URLs In reply to
Hi,

There is a plugin which will convert the charachters into "flat" a-z ... i.e an accented "a" would convert to just an "a" when building the categories (instead of an _)

Lemme just have a quick look to see if I can find the plugin 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: [Thomas.] Ampersand in URLs In reply to
Ok, the plugin is called "StaticURLtr", and can be found in Plugins > Download > List All, then goto the last page Smile

Hopefully that will do what you want

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] Ampersand in URLs In reply to
Thanks Andy, great to see you're still around!

I need to display the ampersand as shown in the first post, e.g. Art & Culture should be converted into and built as Art_&_Culture. Thanks again! Smile
Quote Reply
Re: [Andy] Ampersand in URLs In reply to
Sorry, crossposted. Much obliged!
Quote Reply
Re: [Thomas.] Ampersand in URLs In reply to
Thomas. wrote:
Art & Culture should be converted into and built as Art_&_Culture

Ah ok - thats not possible.

& isn't a valid charachter for a URL ... you would probably have to use "and" as a replacement instead.

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!