Forums / General / Transformation - url transliteration

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

eZ debug

Timing: Jan 18 2025 01:13:05
Script start
Timing: Jan 18 2025 01:13:05
Module start 'content'
Timing: Jan 18 2025 01:13:06
Module end 'content'
Timing: Jan 18 2025 01:13:06
Script end

Main resources:

Total runtime1.3377 sec
Peak memory usage4,096.0000 KB
Database Queries69

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0070 587.7109180.8359
Module start 'content' 0.00701.3243 768.5469620.8047
Module end 'content' 1.33130.0062 1,389.351650.1016
Script end 1.3376  1,439.4531 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00350.2607140.0002
Check MTime0.00180.1323140.0001
Mysql Total
Database connection0.00070.053110.0007
Mysqli_queries1.277595.5033690.0185
Looping result0.00070.0548670.0000
Template Total1.293596.720.6467
Template load0.00220.163920.0011
Template processing1.291396.533220.6456
Template load and register function0.00020.011510.0002
states
state_id_array0.00240.179310.0024
state_identifier_array0.00230.168520.0011
Override
Cache load0.00180.1320400.0000
Sytem overhead
Fetch class attribute can translate value0.00110.079230.0004
Fetch class attribute name0.00120.093180.0002
XML
Image XML parsing0.00310.228730.0010
class_abstraction
Instantiating content class attribute0.00000.001590.0000
General
dbfile0.00550.4093240.0002
String conversion0.00000.000430.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
6content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
7content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
9content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
2content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 29
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs