Kunena 6.0.2 released (15 Aug 2022)

The Kunena team has announce the arrival of Kunena 6.0.2 [K 6.0.2] which is now available for download as a native Joomla extension for J! 4.1.x. This version addresses most of the issues that were discovered in K and issues discovered during the last development stages of K 6.0

× Please note: The Kunena project team takes NO responsibility for maintaining nor supporting anything in this category.

Solved Customize categories WHERE clause

8 years 9 months ago - 8 years 9 months ago #1 by jcsoft

I'm using Kunena 3.0.3 with Joomla 2.5

I would like to customize the categories query to display only some categories depending on languages (i'll use specific aliases for this)

Where to find the WHERE clause to edit?
Which .php file to look for?

Last edit: 8 years 9 months ago by jcsoft.

Please Log in or Create an account to join the conversation.

8 years 9 months ago #2 by Matias
Unfortunately there isn't just one query which you can change, this would affect many different places. Kunena doesn't currently have full language support.

Please Log in or Create an account to join the conversation.

8 years 8 months ago - 8 years 8 months ago #3 by jcsoft
Thank you very much for your answer, Matias!

Meanwhile i put some printf() and print_r() around to try to understand how it works, and finally achieved it by myself, well, kunena is a very clean code! :)

!!!This hack works for Kunena 3.0.3 and Joomla 2.5!
Other versions not tested!!!

All data i need is in the class KunenaViewCategory.
i just needed to modify this file:


The function i hacked is displayList() to remove some categories from the list.

I manage the category aliases by placing the lang-code before the name to be able to distinguish them, as i didn't find any lang field for categories.
So, for example, website alias became both en-website, fr-website, it-website etc.
This way i just need to hide the categories that doesn't begin with the current lang-code.

Here's the code:
function displayList($tpl = null) {
		$this->Itemid = $this->get ( 'Itemid' );
		$this->category = $this->get ( 'Category' );
		if ($this->category->id && ! $this->category->authorise('read')) {
		$this->message_ordering = $this->me->getMessageOrdering();
		$this->categories = $this->get ( 'Categories' );
		$this->pending = $this->get ( 'UnapprovedCount' );
		$this->moderators = $this->get ( 'Moderators' );
		$this->sections = isset($this->categories[0]) ? $this->categories[0] : array();
		if ($this->category->isSection()) {
// TODO: turn this on:
/*			if ($this->me->isAdmin($this->category)) {
				$url = "index.php?option=com_kunena&view=category&layout=manage&catid={$this->category->id}";
				$this->category_manage = $this->getButton($url, 'manage', 'category', 'moderation');
		if ($this->me->exists()) {
			$this->markAllReadURL = KunenaRoute::_();
		$errors = $this->getErrors();
		if ($errors) {
// here i add some code to hack category list, i need to display current language categories only!
// i manage categories by placing the lang-code [en, fr, ...] before the category name itself (like en-website-category, fr-website-category, ...)
	//retrieve lang code
	$jcsoft_language = &JFactory::getLanguage();
	$jcsoft_lang_code_array = explode('-',$jcsoft_language->getTag());
	$jcsoft_lang_code = $jcsoft_lang_code_array[0];
	//check if there are categories in other languages and unset them
	foreach ($this->categories as $jc_idx => $jc_main_cat) {
		foreach($jc_main_cat as $jc_inner_idx => $jc_cat) {
			$jc_cat_explo = explode("-", $jc_cat->alias);
			$jc_cat_lang = $jc_cat_explo[0];
			if($jcsoft_lang_code==$jc_cat_lang) {
				// this is what i need! -do nothing-
			} else {
				// don't want these categories, remove from array
	// finally check if there are some empty main categories (the parents of the removed ones) and unset them
	foreach($this->categories as $jc_idx => $jc_main_cat) {
		if(empty($jc_main_cat)) {
// that's it, now it can be displayed
		$this->display ($tpl);

A similar hack could be extended to the other objects and functions (category/views.html.php#displayDefault(), topic/..., search/...) to make language categories indipendent, but this way if, for exampe, a -fr- user searches for an item, he will not see the results from non-fr- categories.

Hope it helps.

... i love php!
Last edit: 8 years 8 months ago by jcsoft.
The following user(s) said Thank You: Matias, Jiminimonka

Please Log in or Create an account to join the conversation.

8 years 8 months ago #4 by Matias
Didn't think of that. :)

Thanks for saying that Kunena is easy to modify -- Kunena 3.1 will be even easier and you can do much more inside the template.

Please Log in or Create an account to join the conversation.

  • Not Allowed: to create new topic.
  • Not Allowed: to reply.
  • Not Allowed: to edit your message.
Time to create page: 0.073 seconds