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-&gtid; //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

4 Comments.

  1. This is an excellent reference. Thanks for posting this, Andy!

    Kind regards,
    Nick

  2. hey thanks for the above code reference but can we get layout parameter from url.
    JRequest is deprecated so how i can get that variable ?

  3. 我々は、9月にはすでに冬と春が到着した月です!日が軽く、カラフル取得、それに暖かく、カラフル、花の咲く季節の服を取得します。それは私達が私達の店に来ている新しいコレクション春/夏2015分の2014ティンバーランドを記述することができます正確にどのようにあります!

  4. Order a 1/2 size larger for this shoe than you would for any other adidas golf adidas NMD originals Mid City Sock PK Boost. It’s not a tight fit but a little too snug for my taste. Also, I never bought golf shoes with “white mesh” before and what a big mistake, because I am a “clean” freak and the white mesh uppers gets dirty in no time during the round and it just looked horrible after the round.
    adidas Performance Men’s Messi 16.3 IC Indoor Football Soccer Shoe Black-Green