• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

accents in url

diego222

Active member
#1
Hi

There's no problem accesing the forum, but when we have an url with an accent, it changes to "html code" instead of directly put it with the accent. Example:

Code:
http://xenforo.com/community/threads/probando-acentos-canci%C3%B3n.6368/
instead of

Code:
http://xenforo.com/community/threads/probando-acentos-canción.6368/
And I supose it will happen with "Ñ" too.

When we paste it in mozilla/chrome/etc... it change automatically, but when we paste in some text editor or even in a navigator (before pressing Enter), it have html code on url.
 

HWS

Well-known member
#2
It is safer that way. Not all browsers understand foreign characters in URLs and the link will fail without the encoding.

It is not HTML btw, it is url-encoding standard.
 

diego222

Active member
#3
well... html.. url-encoding, I didn't know how to say it :). I mean if there's something we can do to when we write "acción" it changes automatically to "accion" in url. And when we write "españa" it change automatically to "espana".

But then, there's no problem having it with accents?
 

Jake Bunce

XenForo moderator
Staff member
#4
library/XenForo/Link.php

I think you want these functions:

buildIntegerAndTitleUrlComponent()
getTitleForUrl()


There is a $romanize flag in those functions which might be what you need. You could change the default value to true. That will replace accented characters with non-accented ones thereby avoiding all URL encoded characters.
 

diego222

Active member
#5
:oops: too complicated for me.

But it doesn't matter. If there's no problem with browsers or with google (like it or not, G is God), then it's fine.
 
#6
Edit the file library/XenForo/Link.php.

Find:

Code:
public static function buildIntegerAndTitleUrlComponent($integer, $title = '', $romanize = false)
Change it to:

Code:
public static function buildIntegerAndTitleUrlComponent($integer, $title = '', $romanize = true)
Save the file and re-upload it. ;)

So if you make a thread with this title: "Al niño le gusta jugar fútbol", the thread URL will be: http://www.yourdomain.com/threads/al-nino-le-gusta-jugar-futbol.3719/
 

imthebest

Well-known member
#11
Sorry for necroposting but is there a better way (without file edits) to prevent accents and strange characters like "ñ" to appear on the URLs generated by XF?