Displaying items by tag: k2 search

In fact, more precise would be to say that it's working only for latin characters. This problem is rather "old", but I decided to publish my solution here, after it's been 8 months since I published it on K2 forum and since then they have only developer version with this bug repaired.

After upgrading to 2.7.1 you might've noticed that filter in backend stopped working for all except latin characters! It simply ignores entry. In my case, it's cyrillic. Just try it. You don't even have to have cyrillic titled items or categories, filter just acts like nothing happened. Now I know it's problem for all who use any other language or character set but strictly latin. It's unicode problem. So, until there's new stable version of K2, in case you don't want to have developer version (where they repaired this) on your site, here's what you have to do:

You have to change all the following administrator\components\com_k2\models files:
categories.php, items.php, comments.php, tags.php, extrafields.php, usergroups.php,users.php. These are simply all the files that make K2 lists of some kind.

Wherever you have

$search = trim(preg_replace('/[^a-zA-Z0-9\s\-_]/', '', $search));


function getData()

in listed files, adding unicode modifier to preg_replace would solve this. So replace upper line(s) with:

$search = trim(preg_replace('(/[^a-zA-Z0-9\s\-_]/)u', '', $search));

Original line simply removes all that is not latin or number or space or dash... therefore, cyrillic letters go away in no second after clicking filter. I hope this tip helps K2 users, sice once again - this is one excellent extension.