Actions

Customising the dynamic page title

From Joomla! Documentation

Revision as of 00:29, 7 March 2011 by Iarp (Talk | contribs)

This will allow you to change the global page title across the entire site. You may customize it to your own liking within your own templates files.

The code needs to go just after the opening <head> element and before <jdoc:include type="head" /> element.


Document title: $document->title

Sitename: $mainframe->getCfg('sitename')


How it would look(currently set to "Document title - Sitename"):

 <?php
 $document =& JFactory::getDocument();
 $document->setTitle($document->title . " - " . $mainframe->getCfg('sitename'));
 ?>


Example (template coding may vary):

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
 <?php
 $document =& JFactory::getDocument();
 $document->setTitle($document->title . " - " . $mainframe->getCfg('sitename'));
 ?>
<jdoc:include type="head" />
.... rest of template file.