Getting Page Properties and Parameters in Joomla

Getting the Application object.


//In Joomla 1.5 you can use the global $mainframe object.
//if your using $mainframe from within a function need to define it as global
global $mainframe;

//As of Joomla 1.6 the $mainframe global will no longer be available. You will need to instantiate it like this.
$mainframe = JFactory::getApplication();

Getting page parameters:


$params =& $mainframe->getParams();
$title = $params->get(‘page_title’);
$desc = $params->get(‘page_description’);

Getting page parameters and menu item properties from menu object:


$menus = &JSite::getMenu(); //returns JMenuSite object
$menu= $menus->getActive(); //gets current page menu item properties

//retrieve view layout menu item parameters
$params = new JParameter( $menu->params );
$title = $params->get('show_title');
$contest = $params->get('contest_id');

//retrieve menu item parameters
$mID = $menu->id; //menu item id
$route = $menu->route; //page sef url path
$qry = $menu->link; //query string
$alias = $menu->alias; //menu item alias
$comp = $menu->component; //component
$opt = $menu->query[‘option’]; //component
$id = $menu->query[‘id’]; //article id
$cid = $menu->query[‘cid’]; //category id
$view = $menu->query[‘view’]; //view

Get Global Config Parameters:


$mainframe->getCfg( 'sitename' );

Get global parameters of a component:


$params = $mainframe->getParams('com_content');
$val = $params->get('paramname');

//also do it this way using component helper class
jimport('joomla.application.component.helper');
$params = &JComponentHelper::getParams('com_content');
$val = $params->get('paramname');

Get Template name being used for current page:


$mainframe->getTemplate();
or
 JSite::getTemplate();

Leave a comment

0 Comments.

Leave a Reply


[ Ctrl + Enter ]