Transformation - url transliteration

Author Message

Zdenek Ziegler

Monday 18 April 2005 10:09:54 am

Hi,
I read about transformations in transform.ini, tried some modifications to *.tr files, but still not able to do this:
I need to transform "_" to "-" in urls, I know that in ez 3.4 it was done by url transliteration, but I'm not able to do it in ez 3.5 with its integrated transformations.
Is it also possible to transform some characters from user input in xml and text fields to prevent displaying &#xxxx on my pages?
Thanks for help,
Hi Zdenek

Jan Borsodi

Tuesday 19 April 2005 5:47:42 am

The code for transforming the text is now done in <i>lib/ezi18n/classes/ezcodemapper.php</i> in the functions <i>generateCommandCode()</i> and <i>executeCommandCode()</i>.
But I would not recommend modifying this code directly since it involves kernel changes.
In the worst case at least create a new command for url cleanup and configure the <i>transform.ini</i> to use this.

As for the &# characters, we don't have any support for transforming those at the moment. There are also lots of potential problems with automatic filtering of those entities.

--
Amos

Documentation: http://ez.no/ez_publish/documentation
FAQ: http://ez.no/ez_publish/documentation/faq

Zdenek Ziegler

Tuesday 19 April 2005 6:50:26 am

Thank for your reply!
I tried to put my new command to <i>transform.ini</i>:

[urlalias]
Commands[]=url_clean

I edited <i>basic.tr</i> and also <i>latin.tr</i>, where I defined to map space to "-". But it doesn't work.
So could you please post me an example how can this be done?
Thank you very much,
regards,
Zdenek

Jan Borsodi

Wednesday 20 April 2005 6:35:41 am

> I edited basic.tr and also latin.tr, where I defined to
> map space to "-". But it doesn't work.

You will have to do it in PHP code, if you look at the <i>executeCommandCode()</i> and <i>generateCommandCode()</i> I mentioned you will see that it performs a certain regexp replace on the resulting text.
What you need to do is to copy the code (from if() to else) and make a new command, e.g. url_clean.

You can try this code:

else if ( $command['command'] == 'url_clean' )
{
    $text = strtolower( $text );
    $text = preg_replace( array( "#[^a-z0-9_ -]#",
                                 "/ /",
                                 "/--+/",
                                 "/^-|-$/" ),
                          array( " ",
                                 "-",
                                 "-",
                                 "" ),
                          $text );
    return true;
}

Also the <i>generateCommandCode()</i> must be implemented, it will generate this PHP code in a file for later execution.

--
Amos

Documentation: http://ez.no/ez_publish/documentation
FAQ: http://ez.no/ez_publish/documentation/faq

Zdenek Ziegler

Monday 25 April 2005 1:20:47 am

Thank you very much, it works!

Samuel GRAU

Thursday 14 September 2006 2:09:53 am

I have equivalent needs but I'm not sure to have understood how to make it work.
Could you retrace what to do from the begining.
Thx.

Certification URL :: http://ez.no/certification/verify/219433

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.