- Posts: 1
COMMUNITY FORUM
- Forum
- K2 Community Forum
- English K2 Community
- [SOLVED] Hide empty categories in k2 Tools module (cat. menu)
[SOLVED] Hide empty categories in k2 Tools module (cat. menu)
- KE Communication
- Topic Author
- Offline
- New Member
Less
More
9 years 1 month ago #146803
by KE Communication
Hide empty categories in k2 Tools module (cat. menu) was created by KE Communication
How can I make it that only categories with published items show up in the Module (cat. menu list version)?
Please Log in or Create an account to join the conversation.
- Lefteris
- Offline
- Moderator
Less
More
- Posts: 8743
9 years 1 month ago #146809
by Lefteris
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Lefteris on topic Hide empty categories in k2 Tools module (cat. menu)
The module only checks for the publishing status of the categories. If you want to hide a category just unpublish it.
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Rupert Griffiths
- Offline
- Junior Member
Less
More
- Posts: 30
8 years 11 months ago #148364
by Rupert Griffiths
Replied by Rupert Griffiths on topic Hide empty categories in k2 Tools module (cat. menu)
I managed to do this.
About line 550 - 570 in root/modules/mod_k2_tools/helper.php.
Change
foreach ($rows as $row)
{
if ($params->get('categoriesListItemsCounter'))
{
$row->numOfItems = ' ('.modK2ToolsHelper::countCategoryItems($row->id).')';
}
else
{
$row->numOfItems = '';
}
if (($option == 'com_k2') && ($view == 'itemlist') && ($catid == $row->id))
{
$active = ' class="activeCategory"';
}
else
{
$active = '';
}
if (modK2ToolsHelper::hasChildren($row->id))
CHANGE TO
foreach ($rows as $row)
{
if ($params->get('categoriesListItemsCounter'))
{
$itemnumber = modK2ToolsHelper::countCategoryItems($row->id);
}
if ($itemnumber==0)
{
$active = ' class="hidden"';
}
else
{
$active = '';
}
if (modK2ToolsHelper::hasChildren($row->id))
About line 550 - 570 in root/modules/mod_k2_tools/helper.php.
Change
foreach ($rows as $row)
{
if ($params->get('categoriesListItemsCounter'))
{
$row->numOfItems = ' ('.modK2ToolsHelper::countCategoryItems($row->id).')';
}
else
{
$row->numOfItems = '';
}
if (($option == 'com_k2') && ($view == 'itemlist') && ($catid == $row->id))
{
$active = ' class="activeCategory"';
}
else
{
$active = '';
}
if (modK2ToolsHelper::hasChildren($row->id))
CHANGE TO
foreach ($rows as $row)
{
if ($params->get('categoriesListItemsCounter'))
{
$itemnumber = modK2ToolsHelper::countCategoryItems($row->id);
}
if ($itemnumber==0)
{
$active = ' class="hidden"';
}
else
{
$active = '';
}
if (modK2ToolsHelper::hasChildren($row->id))
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
- Offline
- Platinum Member
Less
More
- Posts: 15920
8 years 11 months ago #148403
by Krikor Boghossian
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Krikor Boghossian on topic Hide empty categories in k2 Tools module (cat. menu)
Rupert keep a backup of this edit (or the URL of the thread in this case) because you will need to reapply it when you update K2.
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Rupert Griffiths
- Offline
- Junior Member
Less
More
- Posts: 30
8 years 11 months ago - 8 years 11 months ago #148423
by Rupert Griffiths
Replied by Rupert Griffiths on topic Hide empty categories in k2 Tools module (cat. menu)
Yes I will thanks. Updates are not too frequent ;p
Here is improved replacement code - to keep the "active" class for active categories:
Here is improved replacement code - to keep the "active" class for active categories:
foreach ($rows as $row)
{
if ($params->get('categoriesListItemsCounter'))
{
$itemnumber = modK2ToolsHelper::countCategoryItems($row->id);
}
if ($itemnumber==0)
{
$active = ' class="hidden"';
}
else
{
if (($option == 'com_k2') && ($view == 'itemlist') && ($catid == $row->id))
{
$active = ' class="activeCategory"';
}
else
{
$active = '';
}
}
if (modK2ToolsHelper::hasChildren($row->id))
Last edit: 8 years 11 months ago by Krikor Boghossian.
Please Log in or Create an account to join the conversation.
- Forum
- K2 Community Forum
- English K2 Community
- [SOLVED] Hide empty categories in k2 Tools module (cat. menu)