accents in url

diego222

Active member
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.
 
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.
 
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?
 
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.
 
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/
 
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?
 
Top Bottom