eZ Community » Forums » Developer » problem with url addresse with accent
expandshrink

problem with url addresse with accent

problem with url addresse with accent

Friday 19 April 2013 4:41:43 pm - 12 replies

Hello ezcommunity;

I have a website in french. in my blog page i am using the tagcloud with all the keywords that the editors choose for each blog post.

My problem is with the keywords which have accent. like "accessibilité". 

when i click i have /content/keyword/accessibilité and the result is 

The page cannot be displayed...

when i replace the link to /content/keyword/accessibilite

i have my result.

has anyone any idea how i can solve my problem?

I have the same problem with my search as well.

Friday 19 April 2013 10:32:30 pm

Hello,

Yes this is the default url mechanisms. You could modify it via overriding transform.ini file. Each block, for example [urlalias] use one or more filter. 

I recommand you to create a new block group and "say" to eZ, using your new group. For that you have on site.ini / [URLTranslator] / TransformationGroup

When done, don't forget to update all urls via

 $php bin/php/updateniceurls.php -s your_admin_siteaccess

Cheers

Philippe

Monday 22 April 2013 12:29:21 pm

Thank you very much for your answer Philippe, 

I changed  TransformationGroup    to urlalias_iri , i update the updateniceurls.php , but i didnt change the urls.

should i change something again?

I have to add i updated updateniceurls.php only for my french siteaccess

Monday 22 April 2013 5:08:48 pm

Another thing is that, i dont have any problem with the other links within my site.

i have the words with accent in my menu but the problem only comes from the tagcloud and search results.

Tuesday 23 April 2013 9:45:58 am

That's strange.. For your tags, if you're using ezkeywords, have a look to "ezkeyword" table, to check if you have data on it..

Tuesday 23 April 2013 10:51:54 am

this is what i have in ezKeyword table in my db:

 

class_id

id

keyword

 Modifier  Éditer en place  Copier  Effacer 20 67 révolution numérique

Tuesday 23 April 2013 10:52:49 am

Content urls are managed quite differently from "system" urls - which are in fact all urls not used for content and not managed via virtual urls in the admin interface.

For keywords:

- check data in the db

- do a dump of the $Module var in the php code of the tags view

For search - another problem altogether I reckon - here word to be searched for is passed via query string:

- enable debug output to see the request sent to solr by ez. does it have the accent or not?

- use the solr admin interface to check out what happens when you send directly to solr requests with and without accent

Tuesday 23 April 2013 5:08:01 pm

Hi Gaetano and thank you for ur answer.

In fact, For search , i am not using EzFind so i dont use Solr in admin interface.

And for keywords , is it possible to tell me in which file, i can find php code of tag view please? is it the php file in autoload of ezwebin ? eztagcloud.php?

then i was looking for my problem in docs and i saw this is something that should be generate automatically.

isnt it a bug ?

Tuesday 23 April 2013 6:13:48 pm

In eztagcloud.php i have added a function:

function replaceAccents($text) { 

                             $unwanted_array = array(    'Š'=>'S', 'š'=>'s', 'Ž'=>'Z', 'ž'=>'z', 'À'=>'A', 'Á'=>'A', 'Â'=>'A', 'Ã'=>'A', 'Ä'=>'A', 'Å'=>'A', 'Æ'=>'A', 'Ç'=>'C', 'È'=>'E', 'É'=>'E',                            'Ê'=>'E', 'Ë'=>'E', 'Ì'=>'I', 'Í'=>'I', 'Î'=>'I', 'Ï'=>'I', 'Ñ'=>'N', 'Ò'=>'O', 'Ó'=>'O', 'Ô'=>'O', 'Õ'=>'O', 'Ö'=>'O', 'Ø'=>'O', 'Ù'=>'U',                            'Ú'=>'U', 'Û'=>'U', 'Ü'=>'U', 'Ý'=>'Y', 'Þ'=>'B', 'ß'=>'Ss', 'à'=>'a', 'á'=>'a', 'â'=>'a', 'ã'=>'a', 'ä'=>'a', 'å'=>'a', 'æ'=>'a', 'ç'=>'c',                            'è'=>'e', 'é'=>'e', 'ê'=>'e', 'ë'=>'e', 'ì'=>'i', 'í'=>'i', 'î'=>'i', 'ï'=>'i', 'ð'=>'o', 'ñ'=>'n', 'ò'=>'o', 'ó'=>'o', 'ô'=>'o', 'õ'=>'o',                            'ö'=>'o', 'ø'=>'o', 'ù'=>'u', 'ú'=>'u', 'û'=>'u', 'ý'=>'y', 'ý'=>'y', 'þ'=>'b', 'ÿ'=>'y' );                                                              return strtr( $text, $unwanted_array );                }

 

just before 

class eZTagCloud{...

 

and in the last line i added:

 

$tagCloud[] = array( 'font_size' => $size,

                             'count' => $value,

                              'tag' => $key,

                              'tagNoAccent' => replaceAccents($key) );

 

then in my template i added:

 

href={concat( "/content/keyword/", $tag[' tagNoAccent']|rawurlencode )|ezurl()}

my tagcloud works:

/content/keyword/accessibilite

but still in my tags i have www.myurl/(tag)/accessibilité

 

 

Wednesday 24 April 2013 10:26:18 am

the php code executing when you go to url content/keyword/xxx is the file kernel/content/keyword.php

it does little in fact, the heavy lifting is left to the template: design/standard/templates/content/keyword.tpl

which in turn uses the fetch function content/keyword, defined in kernel/content/ezcontentfunctioncollection.php

ps: I just tested by using the url with an accent on a 4.7 install, and it works without problems: I get a page with no keyword found. In fact my theory of the problem being related to the database layer might be wrong: if it was the case, you also would get a page with no keywords, but not an access-denied page.

Are you sure it's not a problem related to php / apache configuration?

Last thing: the tagcloud is normally shown using the tagcloud template operator (if you are using ezdemo design). This means you are using template tagcloud/tagcloud.tpl from ezdemo design in ezdemo extension (you can see this at bottom of the page when you have debug enabled w. list of used templates). If you look at that tpl, you will see that it has a rawurlencode() call done to produce correct urls with accents. Can you do a "show source" in the broswer when you are looking at the tag-cloud page, and see exactly how the link is written down?

Thursday 25 April 2013 10:49:37 am

Gaetano;

Thank you very much for your answer.

I did a dump on $Module (kernel/content/keyword.php) with no result , in  show source  i have : /content/keyword/accessibilit%C3%A9

I figure it out that on an other website which is installed in another server i had no problem with my keywords. 

in my database i had used utf8_unicode_ci , so i started to change all the table to utf8_general_ci

i clear all the caches , but still it doesnt work.

do you have any idea where the problem comes from?

Friday 26 April 2013 9:56:34 am

Small note: any utf8_xxx encoding in the db will do. They all mean: "use utf8 to encode data, but use a different algorithm for sorting".

Url in source is right: properly url-encoded.

if $Module is undefined, you definitely have a problem with the routing layer, not the data layer.

Which version of ez are you using?

Did you add any custom code to config.php?

Friday 26 April 2013 6:40:07 pm

I am using ezpublish 4.6 and i have never changed anything in config.php!

I am wondering if it is related somehow to something on an configuration file on server?

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from