Keyword

Itemid on mod_k2_content is not appended

More
14 years 1 day ago #74364 by Markus Thiel
Replied by Markus Thiel on topic Itemid on mod_k2_content is not appended
This "fix" wont work for me :(... I have like 240 sub categories and that wont work in a menu ;)

Any other ideas?

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

More
13 years 6 months ago #74365 by ngyukman
Replied by ngyukman on topic Itemid on mod_k2_content is not appended
I just did some hack on this to make sure my client is happy to see breadcrumbs works as expected.

Hope it helps someone.

 

First add the following code in components\com_k2\models\itemlist.php

function getCategoryParent ($catid) {
$user = &JFactory::getUser();
$aid = (int) $user->get('aid');
$catid = (int) $catid;
$db = &JFactory::getDBO();
$query = "SELECT parent FROM #__k2_categories WHERE id={$catid} AND published=1 AND trash=0 AND access<={$aid} ORDER BY ordering ";
$db->setQuery($query);
$rows = $db->loadObjectList ();
if (count ($rows) == 1)
return $rows[0]->parent;
else
return -1;
}

 

The second thing to do is to amend the function getItemRoute in components\com_k2\helpers\route.php

function getItemRoute($id, $catid = 0) {
$needles = array (
'item'=>(int)$id,
'itemlist'=>(int)$catid,
);
$link = 'index.php?option=com_k2&view=item&id='.$id;

if ($item = K2HelperRoute::_findItem($needles)) {
$link .= '&Itemid='.$item->id;
}
else
{
$parentCatId = K2ModelItemList::getCategoryParent ($catid);
while ($parentCatId > 0)
{
$needles = $parentCatId;
if ($item = K2HelperRoute::_findItem($needles))
{
$link .= '&Itemid='.$item->id;
break;
}
$parentCatId = K2ModelItemList::getCategoryParent ($catid);
}
}
return $link;
}


 

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


Powered by Kunena Forum