Change the URL/URI separator

Author Message

Dominic Luechinger

Thursday 28 December 2006 4:25:07 pm

Is there a possibility to change the URL separator (by default: "_") in the ez publish.
The problem is, that this constitution isn't usefull for SEO (Search engine optimization), because a link like http://ez.no/company/contact_form will be interpreteted as "contact_form" and not as "contact","form".
See more on: http://www.prweaver.com/blog/2004/08/26/2-hyphen-and-underscore

Thank's

kracker (the)

Friday 29 December 2006 2:23:23 am

I've heard a lot of talk about this feature request.
I hear it's ... complicated and deeply involved.

That said back in 2003 it did not seem so complicated,
<i>http://ez.no/community/forum/setup_design/nice_url_delimiter_change_to_</i>

While the above thread is 'a' starting point,
It seems much of this functionality has since been abstracted a few times.

Follow the php code's execution order...
file, 'kernel/classes/ezcontentobjecttreenode.php', function 'pathWithNames()'
file, 'kernel/classes/ezurlalias.php', function 'convertToAlias()'

  /*!
     \static
     Converts the path \a $urlElement into a new alias url which only conists of characters
     in the range a-z, numbers and _.
     All other characters are converted to _.
     \return the converted element

     \example
     'My car' => 'my_car'
     'What is this?' => 'what_is_this'
     'This & that' => 'this_that'
     'myfile.tpl' => 'myfile_tpl',
     '<F8><E6><E5>' => 'oeaeaa'
     \endexample
    */
    function convertToAlias( $urlElement, $defaultValue = false )
    {
        include_once( 'lib/ezi18n/classes/ezchartransform.php' );
        $trans =& eZCharTransform::instance();

        $urlElement = $trans->transformByGroup( $urlElement, 'urlalias' );
        if ( strlen( $urlElement ) == 0 )
        {
            if ( $defaultValue === false )
                $urlElement = '_1';
            else
            {
                $urlElement = $defaultValue;
                $urlElement = $trans->transformByGroup( $urlElement, 'urlalias' );
            }
        }
        return $urlElement;
    }

file, 'lib/ezi18n/classes/ezchartransform.php', function 'transformByGroup()'
file, 'lib/ezi18n/classes/ezcodemapper.php', function 'executeCommandCode()'

 function executeCommandCode( &$text, $command, $charsetName )
    {
        if ( $command['command'] == 'url_cleanup' or
             $command['command'] == 'identifier_cleanup' )
        {
            $text = strtolower( $text );
            $text = preg_replace( array( "#[^a-z0-9_ ]#",
                                         "/ /",
                                         "/__+/",
                                         "/^_|_$/" ),
                                  array( " ",
                                         "_",
                                         "_",
                                         "" ),
                                  $text );
            return true;
        }

I believe with some tinkering around here and perhapses a few other locations in the code (one edit for interpretation and one edit for generation ... of-urls-using-dashes-rather-than-underscores) the theory is it's possible. Though this could open up other as of yet unknown breakdowns resulting from these modifications which would need to be addressed for a complete solution.

<i>//kracker
the lifestyle of private modifications which never see distribution is a sad one indeed ... contribute to your local community!</i>

<b>Related threads</b>
<i>http://ez.no/community/forum/general/usability_and_seo
http://ez.no/community/forum/suggestions/url_rewriting_and_whitespaces
http://ez.no/community/forum/general/seo_and_page_head
http://ez.no/community/forum/suggestions/better_urls</i>

Member since: 2001.07.13 || http://ezpedia.se7enx.com/

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