|
In joomla1.0.x, If the active menu links to com_content, we can use the following code to get the active menu linked content's section id and category Id.
global $Itemid;
$activeMenuItemId=$Itemid;
$params=array();
$sql = "SELECT m.*"
. "\n FROM #__menu AS m"
. "\n WHERE id = ".$activeMenuItemId
. "\n AND published = 1";
$database->setQuery( $sql );
$menuRows = $database->loadObjectList();
if(count($menuRows)){
$linkParts=explode('?',$menuRows[0]->link);
$parts=explode('&',$linkParts[1]);
foreach($parts as $p){
$nv=explode('=',$p);
$params[$nv[0]] = $nv[1];
}
$isContentMenu=0;
if($params['option']=='com_content'){
$isContentMenu=1;
if($params['task']=='section'){//section
$secid=$params['id'];
unset($catid);
}else if($params['task']=='category'){//category
$secid=$params['sectionid'];
$catid=$params['id'];
}else{//article
$articleId=$params['id'];
$sql = "SELECT c.sectionid,c.catid"
. "\n FROM #__content AS c"
. "\n WHERE c.id = ".$articleId;
$database->setQuery( $sql );
$sectionCat = $database->loadObjectList();
if(count($sectionCat)){
$secid=$sectionCat[0]->sectionid;
$catid=$sectionCat[0]->catid;
}
}//end task
}//end option
}//end menu
The following Joomla1.0.x extensions are all using the above code. Mod_latestnewsByCategoryOrSection mod_mostreadCategoryOrSection
|
| Recommend Read | |