Get active menu linked Content's section Id and category Id in Joomla1.5.x
Written by Li   

In joomla1.5.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.

	 $menus = &JSite::getMenu();

	 $currentMenu  = $menus->getActive();   
    $menuOption=$currentMenu->query['option'];

	if($menuOption=='com_content'){
	   $menuView=$currentMenu->query['view'];
	   if($menuView=='section'){
	     $secid=$currentMenu->query['id'];	    
	   }elseif($menuView=='category'){
	     $catid=$currentMenu->query['id'];	        
	   }else if($menuView=='article'){
	   	$articleId=$currentMenu->query['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;
			}
	   }
	}

The following Joomla1.5.x categoryOrSection series extensions are all using the above code. Joomla categoryOrSection series extensions




 
Recommend Read