Joomla default menu (homepage), view and option variables in index.php template file

Joomla default menu (homepage), view, option variables in index.php

// if a section set background body type for background image
$menu = &JSite::getMenu();

// echo the menu item name
echo $menu->getActive()->name;
echo $menu->getActive()->id; // id number

if ( JRequest::getCmd('view') === "section" ) {

// connect to database

]$db = &JFactory::getDBO();
$temp   = JRequest::getString('id');
$temp   = explode(':', $temp);           
$id   = $temp[0];

$db->setQuery('SELECT title FROM #__sections WHERE id='.$id);  
$sname=$db->loadResult();
$sname=str_replace(" ","_",$sname);
$sname=str_replace("'","",$sname);
echo "_".strtolower($sname);
}

elseif ( ($menu->getActive() == $menu->getDefault()) || ( JRequest::getCmd('view') === "frontpage" ) ) {
echo "_homepage";
}

Leave a Reply