Share » Forums » General » Transformation - url transliteration

Transformation - url transliteration

Transformation - url transliteration

Monday 18 April 2005 10:09:54 am - 5 replies

Author Message

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

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

36 542 Users on board!

Forums menu