Recent Topics

1 May 18, 2014 02:25    

Why does the system force lower-case letters in the URL slug field? I needed for a project some capital letters in the URL, but seem not be allowed to use these.

Is there a way to switch off this limitation or is there a very good reason to have it?

2 May 18, 2014 11:48

@ramadama Maybe this is not the main reason, but it's a way to standarize slugs behavior across case sensitive/insensitive systems.

If you really need to include capital letters in your item's slugs, here is a little hack that could be useful:

Note: the line numbers are included as a reference assuming that you are working with a 5.0.9 standard release, which means that none of the mentioned files have been touched before.

1) Go to the file blogs/conf/_advanced.php and add the following lines at the end of it (before the PHP closing tag ?>):


// By setting this variable to false, the case sensitive slugs feature will be disabled
$case_sensitive_slugs = true;

2) Go to the file blogs/inc/items/model/_item.funcs.php, find the function urltitle_validate and replace the line:


global $DB, $Messages;

with


global $DB, $Messages, $case_sensitive_slugs;

3) A little bit below in the same function, locate this line:


$urltitle = strtolower( trim ( $urltitle ) );

and replace it with the following block:


$urltitle = trim ( $urltitle );

if( !$case_sensitive_slugs ) $urltitle = strtolower( $urltitle );

Please note that this might not work as expected in Windows environments. I only tested in a Linux box.

3 May 18, 2014 20:03

Thanks Manuel, this hack works perfectly (used on a productive server, which might run on Linux).

One more question: if i work with this changes only for creating this posts (with capital letter containing URLs) and will get rid of the hack afterwards, will the by then generated URLs keep their capital letters?

4 May 20, 2014 05:40

@ramadama yes, the capital letters will remain unless you edit the post. In that case, if any of the slug that contains a capital letter is the canonical URL, a new lower-cased slug will be added and set as the canonical.


Form is loading...