Skip to content

Fix for a problem with Joomla K2 and sh404sef

First some explanation about the problem.

The situation is when you have a Joomla 1.5 site with sh404sef 2.1.4 component and you want to add additional section for a blog for example and you want to use K2 2.4 for this.

So in this case you have additional menu item called for example ‘blog’ where you see a blog of your K2 articles. But you also want to have the tags and the search.

The problem is that when you hit on a tag you go to the page with the tags but you don’t see the other modules for the ‘blog’ item (you are redirected to a page without Itemid).

The same is with the search results page.

And one additional fix for a prefix in the url for your K2 blog.

To fix this issues:

1. Go to modules/mod_k2_tools/tmpl/search.php

and add this line in front inside of some php:

$Itemid = JRequest::getInt( ‘Itemid’);

then on line 16 change this:

<form action=”<?php echo JRoute::_(‘index.php?option=com_k2&view=itemlist&task=search’); ?>” method=”get”>

to:

<form action=”<?php echo JRoute::_(‘index.php?option=com_k2&view=itemlist&task=search&Itemid=’.$Itemid); ?>” method=”get”>

2. Go to components/com_k2/helpers/route.php

on line 111 you see this:

$link = 'index.php?option=com_k2&view=itemlist&task=tag&tag='.urlencode($tag);

 if ($item = K2HelperRoute::_findItem($needles)) {
 $link .= '&Itemid='.$item->id;
 }
 ;

change it to this:

$link = 'index.php?option=com_k2&view=itemlist&task=tag&tag='.urlencode($tag);

$Itemid = JRequest::getInt( 'Itemid');

$link .= '&Itemid='.$Itemid;

3. To put a prefix in the URL for your blog go to components/com_k2/sef_ext/com_k2.php

In lines 97 and 127 there should be a starting case statements:

case 'item':
case 'itemlist':

After each one of those add this:

$title[] = 'blog';

You clould replace the word blog with that you think should be your word.

Published inCodingJoomla