Monday 15 April 2013

Customize the Page Title in your Component Joomla 2.5/3.0

To customize the any Page Title, please follow the below instructions.

// Create the document object.
$docHTML = JFactory::getDocument();

// Fetch the Default Page title.
$defaultPageTitle = $docHTML->getTitle();

// Change the New page title as per your needs.
$newPageTitle = $pageTitle . ' - '. $docHTML->getTitle()

// Set the New Page Title.
$docHTML->setTitle(  $newPageTitle );

// To display the above set new page title.
Please, Open the Index.php file from the selected templates folder e.g. root/templates/yourSelectedTemplate/index.php. Then, add the below code on the top.
//And the below codes just underneath the 
defined ( '_JEXEC' ) or die ( 'Restricted access' ); 

// Display the Page Title.
$app = JFactory::getApplication(); 
$this->setTitle( $this->getTitle()  . ' - ' . $app->getCfg( 'sitename' ) );

No comments:

Post a Comment

Please post any queries and comments here.