Search code examples
joomlajoomla3.3

Joomla 3 - use article title as Browser Page Title instead of menu item title


I'm using Joomla 3.3.4, and I have all of my pages linked to menu items. I can't figure out how to get the article title to show in the <title> tag of the page, rather then the Menu item title.

For eg. My Menu item title is 'transmissions' because it's a sub-menu item to 'light duty'. My page title is 'Light Duty Transmissions'. When you browse to the page through the main menu, the <title> tag is 'transmissions' and I need it to be the article title: 'Light Duty Transmissions'.

I know that I can change each 'Browser Page Title' setting for each menu item and individually override the menu item title. But I'm worried this will create confusion in the future when trying to update page titles.

Thanks, Mel


Solution

  • You have to make a simple addition to article template.

    You have to copy:

    /components/com_content/views/article/tmpl/default.php
    

    To the template folder (if doesn't already exist):

    /templates/*your_template/html/com_content/article/default.php
    

    And add these two lines at the top of the page:

    $document = & JFactory::getDocument();
    $document->setTitle( $this->item->title );
    

    Hope this helps