Silverstripe (Blog module): localisation of Tag Cloud widget

Tags: , , ,

In current version of Silverstripe's Blog module it's impossible to show non-latin tags in Tag Cloud widget — you'll see garbage instead of them:Garbage in Tag Cloud widget

In order to remedy this problem you must open "blog\code\widgets\TagCloudWidget.php" and find this string:

$theseTags = split(" *, *", strtolower(trim($entry->Tags)));

Then replace the call of "strtolower" function with an "mb_strtolower" call:

$theseTags = split(" *, *", mb_strtolower(trim($entry->Tags)));

Please notice that internal codepage for multibyte functions in PHP is already set in "sapphire\main.php",

if (function_exists('mb_http_output')) {
    mb_http_output('UTF-8');
    mb_internal_encoding('UTF-8');
}

So you don't need to do this again.

Also if you have access to php.ini you have an option to not change the code. Instead of this you can overload the ordinary string functions with their multibyte counterparts:

[mbstring]
mbstring.func_overload = 2

Please notice that it doesn't work on .htaccess level now (the current version of PHP at the moment of writing this is 5.3.8). It worked some time ago, but with bugs. This is why they have removed directory-level overloading support.


21 August 2011

Comments (frozen for the time being)

No one has commented on this page yet.


Интернет реклама