Home
Create a custom page title in Joomla 1.0.x
One of the most importart SEO factors there days is the ability to setup unique page titles whic reflect the content of each page. In Joomla 1.0.x this can be a little bit tricky, because it has a standard way of creating a page title.

There are a lot of tools (Artio, OpenSEF) that can create dynamic page titles, but they do more than you want. You just want control over the titles.

If you make these small amount of changes in the Joomla source code, the title will be created from the "Title Alias" that you fill in your back-end panel.

To get Joomla to use the title alias, use this code:

1. Open the following file:

components/com_content/content.php

 

2. Look for the following code:

// page title
 $mainframe->setPagetitle( $row->title );

 

3. Replace the code from 2. to this:

// If title alias < 20 characters, page title will be: Site name - title
 // else page title will be: title alias
 if (strlen($row->title_alias) < 20 )
 {
   $mainframe->setPagetitle( $row->title );
 }else{
   $mainframe->setPagetitlealias( $row->title_alias );
 }
 // END CODE SNIPPET 

 

4. Open the following file:

includes/joomla.php

 

5. Look for the following code:

function setPagetitle( $title=null ) {
 if (@$GLOBALS['mosConfig_pagetitles']) {
   $title = trim( htmlspecialchars( $title ) );
   $title = stripslashes($title);
   $this->_head['title'] = $title? $GLOBALS['mosConfig_sitename'] . '
 - '. $title : $GLOBALS['mosConfig_sitename'];
   }
 }

 

6. Add the following code after the code shown in 5.:

// setPagetitlealias - title of the content page to use tile_alias instead
 /**
 * @param string
 */
 function setPagetitlealias( $title_alias=null ) {
   if (@$GLOBALS['mosConfig_pagetitles']) {
     $title_alias = trim( htmlspecialchars( $title_alias ) );
     $title_alias = stripslashes($title_alias);
     $this->_head['title'] = $title_alias;
   }
 }
  // END CODE SNIPPET 

 

And there you have it. If the "Title alias" from any content now has more characters than 20, that will be the new page title. Enjoy.



Tags:  SEO joomla custom page title how to

Interested in this topic? You might enjoy another article I've written called

Did you like this article? Subscribe to my feed or email to keep updated on new articles.

Spread the word and submit to:
Reddit!Del.icio.us!Facebook!Technorati!StumbleUpon!Newsvine!Furl!Ma.gnolia!
Comments
Add NewSearchRSS
Rohit - Thanks a ton !!!   | 122.163.236.xxx | 2008-01-05 15:29:12
Gravatar image man u rockkkkkkkkk its just so simple.. and i can live with putting my custom title tag in alis rather than having a dedicated field for it..
Ido Fishman - Custom Homepage Title   | 79.179.107.xxx | 2008-05-26 10:00:22
Gravatar image Thanks for the help, I just have 1 more question - do you know how to change the homepage title?
Read more...
Name:
Email:
  Gravatar enabled.
Website:
Title:
UBBCode:
[b] [i] [u] [url] [quote] [code] [img] 
 
 
:angry::0:confused::cheer:B):evil::silly::dry::lol::kiss::D:pinch:
:(:shock::X:side::):P:unsure::woohoo::huh::whistle:;):s
:!::?::idea::arrow:
 
Security Image
Please input the anti-spam code that you can read in the image.
Unsubscribe from e-mail notifications.
 
< Prev
Subscribe
Navigation
Search
Search:
          
Sponsors
   



Blogrush