Tuesday, 29 July 2014 00:00

Missing K2 Categories and Items in Backend

Written by 
Rate this item
(1 Vote)

Have you found that you are missing K2 categories and/or items from the K2 list views in the backend of Joomla?
Then I may have a temporary fix for you.

I have a multilingual site that I admin on, that has been missing K2 categories and items from the backend for quite a while.
What I have found is that when you have a multilingual site, you set each category and item with the language you wish it to be assigned to.

In the List View, the table that shows all your categories or items, it will only show any content that is set to ALL, but none that you may have set to en-GB or fr-FR for example.

A fix was put in place in K2 v2.6.8 but that looks like it may not have fully worked.

My work around requires a modification to core K2 files, so be warned you should make a copy of the files and be aware that any updates to K2 will over write these changes.

The changes themselves are simple. 
You need to modifiy 2 files found in administrator/components/com_k2/models/

These files are called categories.php and items.php and the changes are the same in both files.

Edit the files, either download, save and upload or using an FTP editor component for Joomla!

Search the two files for the following text, which will appear twice, making a total of four changes.

$query .= " AND (c.language = ".$db->Quote($language)." OR c.language = '*')";

I simply modified this and added extra OR to define the languages I wished it to check for, mine code then looks like this:

$query .= " AND (c.language = ".$db->Quote($language)." OR c.language = '*' OR c.language = 'en-GB' OR c.language = 'fr-FR')";

Once this is added to my two files and saved, I go back to K2 admin area and now can see all content for all those defined languages.
There maybe a better way of handling this, but as a quick solution to allow content to be seen in the backend, this works.

It is worth mentioning, that this issues has no impact on content displayed on the frontend, just in the admin side.

If anyone knows a better piece of code to include all languages, then please add to the issue report on github

Read 6441 times Last modified on Tuesday, 29 July 2014 16:13