Keyword

CORE HACK: 404 tag prefix page

  • Matt
  • Matt's Avatar Topic Author
  • Offline
  • Senior Member
More
11 years 7 months ago - 11 years 7 months ago #110122 by Matt
CORE HACK: 404 tag prefix page was created by Matt
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.

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


Powered by Kunena Forum