If you are like me, you don't like pointless pages like this:
getk2.org/show
With the new SEF advanced options of K2, you will get pointless pages if you assign tag listings to a hidden menu to avoid duplicated URLs.
So we are going to 404 the tag prefix page. Due to limitations in Joomla and the lack of careness of the K2 devs, we must do a core hack. Which means every time you update K2 you have to apply the hack again.
Open
components/com_k2/helpers/permissions.php and find
public static function checkPermissions(). Just below the opening bracket paste following code:
// CORE HACK - 404 /show page //
$view = JRequest::getCmd('view');
if ($view != 'itemlist')
{
return;
}
$task = JRequest::getCmd('task');
$itemid = JRequest::getCmd('Itemid');
if ($task == '' && $itemid == '148')
{
JError::raiseError(404, JText::_('K2_NOT_FOUND'));
}
// CORE HACK - 404 /show page END //
Note: Replace the item id of 148 with the item id of your hidden menu.
So in the end you have this:
public static function checkPermissions()
{
// CORE HACK - 404 /show page //
$view = JRequest::getCmd('view');
if ($view != 'itemlist')
{
return;
}
$task = JRequest::getCmd('task');
$itemid = JRequest::getCmd('Itemid');
if ($task == '' && $itemid == '148')
{
JError::raiseError(404, JText::_('K2_NOT_FOUND'));
}
// CORE HACK - 404 /show page END //
$view = JRequest::getCmd('view');
if ($view != 'item')
{
return;
}
$task = JRequest::getCmd('task');
$user = JFactory::getUser();
if ($user->guest && ($task == 'add' || $task == 'edit'))
This works with any prefix name, not just "show". Important is the right item id of your hidden menu.