hm_468x60_09_395
announcement

Joomla Web Hosting

Find the best and most affordable Joomla web hosting provider.

Community Showcase on joomla.org

The Joomla Project is pleased to announce latest undertaking to promote Joomla site

Advertise on JoomlPanel.com

For only $30.00 a month you can advertise on one of the web's largest Joomla websites.

More Changes Coming Soon!

Check back for future changes!

bh_300x250_08_395

Page Titles in Joomla! 1.5

There are 2 objects in Joomla! 1.5 that are extremely powerful and extremely useful for doing some advanced tricks in your template. The first object is JFactory, which is basically the gateway for accessing just about anything in the Joomla! API, and the second is JDocument, which gives you access to your document's properties.

Your document is usually defined as the HTML output from Joomla!, but it could also be a PDF, XML/RSS, or raw output/text. In this case, we are only concerned with the HTML output.

To access your page title, simply add the following code to the top of your template "index.php" file:



$mydoc =& JFactory::getDocument();
$mytitle = $mydoc->getTitle();

?>

That's it. That's all there is to it. Pretty simple, huh? Now, to display your page title within your template, you simply add the following code anywhere in your template "index.php" file that you wish to display the page title:


echo $mytitle; ?>

That's all there is to it. Pretty easy.

 

Modifying Your HTML Title

The next thing we want to do is modify your html title. We will be using the JDocument object that we just accessed. Using this code, you can set the html title of your page:


$conf =& JFactory::getConfig();
$sitename = $conf->getValue('config.sitename');

$mydoc->setTitle($mytitle.' - '.$sitename);

Notice that I used JFactory again to get a copy of the Joomla! configuration, which I then used to get the value of the site name (config.sitename). Then, I used "$mydoc" from the earlier step to set the html title.

Note that this code sets the html title to "Page Title - Site Name". If you want to set it to "Site Name - Page Title", you need to change the setTitle parameter to "$sitename.' - '.$mytitle". In reality, you can set the html title to anything you want, but I personally think "Page Title - Site Name" makes the most sense.

 

Putting it All Together

Using the following code, you are simultaneously getting dynamic access to your page title and setting the value of your html title:



$mydoc =& JFactory::getDocument();
$mytitle = $mydoc->getTitle();

$conf =& JFactory::getConfig();
$sitename = $conf->getValue('config.sitename');

$mydoc->setTitle($mytitle.' - '.$sitename);

?>

 


Resource : http://www.howtojoomla.net/content/view/86/2/

 

 

joomlahosting




Joomla Tutorials

Joomla panel provides easy to use website joomla tutorial free download joomla templates for joomla verssion 1.0x and 1.5x. Here you will learn how to install Joomla, all the way to installing and customizing your own templates.

Tutorials Showcase enables you to build Web sites and powerful web applications. Best of all, Joomla is an open source solution that is freely available to everyone.

Building Web CMS Project

Submit your joomla web to joomlapanel web showcase gallery directories and find the joomla stable extensions : Joomla plugin, joomla module, joomla component, joomla mambot.

Submit your Article blog into our article directories to anchance high web Traffic.

 

Article and Tips trick

Your sohowcase for Travel guide; Hotel, Villas resort, Flight, car website

tutorial