hallo there!
i am trying to create a function outsite of k2 to retrieve the sef url of the k2 item. i write this one but it is not working :/
any help is appreciated!
thank you
i am trying to create a function outsite of k2 to retrieve the sef url of the k2 item. i write this one but it is not working :/
function getK2ItemRoute ($cb_api_version, $id, $catid, $k2item)
{
require_once(JPATH_SITE.DS.'components'.DS.'com_k2'.DS.'helpers'.DS.'route.php');
$needles = array(
'item' => (int) $id,
'category' => (int) $catid
);
$db = JFactory::getDBO();
$select = 'SELECT a.id AS id, a.catid AS catid, a.alias AS alias, c.alias AS catalias FROM #__k2_items AS a LEFT JOIN #__k2_categories AS c ON ( a.catid = c.id ) WHERE a.published = 1 AND a.catid = '.$catid;
$db->setQuery($select);
$k2item = $db->loadObjectList();
//Create the link
$link = JRoute::_(K2HelperRoute::getItemRoute($k2item->id.':'.urlencode($k2item->alias),$k2item->catid.':'.urlencode($k2item->catalias)));
return $link;
}
function _findItem ($cb_api_version, $needles)
{
$component =& JComponentHelper::getComponent('com_k2');
$menus = &JApplication::getMenu('site', array());
if ($cb_api_version < 2) {
$items = $menus->getItems('componentid', $component->id);
} else {
$items = $menus->getItems('component_id', $component->id);
}
$match = null;
foreach ($needles as $needle => $id)
{
foreach($items as $item)
{
if ((@$item->query['view'] == $needle) && (@$item->query['id'] == $id))
{
$match = $item;
break;
}
}
if (isset($match)) {
break;
}
}
return $match;
}
any help is appreciated!
thank you
Edited 11 years 5 months ago by George Nasis · Reason: wrong edit
