API16

JFilterOutput/stringURLUnicodeSlug

From Joomla! Documentation

< API16:JFilterOutput

The "API16" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

Description[edit]

This method implements unicode slugs instead of transliteration.


<! removed transcluded page call, red link never existed >

Syntax[edit]

stringURLUnicodeSlug($string)
Parameter Name Default Value Description
$string $input String to process

Returns[edit]

string Processed string

Defined in[edit]

libraries/joomla/filter/filteroutput.php

Importing[edit]

jimport( 'joomla.filter.filteroutput' );

Source Body[edit]

function stringURLUnicodeSlug($string)
{
        //replace double byte whitespaces by single byte (Far-East languages)
        $str = preg_replace('/\xE3\x80\x80/', ' ', $string);


        // remove any '-' from the string as they will be used as concatenator.
        // Would be great to let the spaces in but only Firefox is friendly with this

        $str = str_replace('-', ' ', $str);

        // replace forbidden characters by whitespaces
        $str = preg_replace( '#[:\#\*"@+=;!&%()\]\/\'\\\\|\[]#',"\x20", $str );

        //delete all '?'
        $str = str_replace('?', '', $str);

        //trim white spaces at beginning and end of alias
        $str = trim( $str );

        // remove any duplicate whitespace and replace whitespaces by hyphens
        $str =preg_replace('#\x20+#','-', $str);
        return $str;
}


<! removed transcluded page call, red link never existed >

Examples[edit]

Code Examples[edit]