Reputation: 297
I'm using Joomla 3.4.8, and I have all of my pages linked to menu items. I can't figure out how to get the menu item title to show in the <title>
tag of the page, rather than only the article title.
For eg. My Menu item title is 'test', when I press the button it shows test but in that menu item there are many articles. when i click on the article in the test page. It only shows the article name and not the menu item. What i want is that it shows the article name + the menu item.
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.
something like this source but with the menu item.
<?php $document=& JFactory::getDocument();
$document->setTitle( $this->item->title ); ?>
Upvotes: 0
Views: 583
Reputation: 186
You can retrieve current active menu item and use the parameters that you need with JApplication with this code:
$active_menu = JFactory::getApplication()->getMenu()->getActive();
Then set the title as you need:
JFactory::getDocument()->setTitle($active_menu->title." - ".$this->item->title);
Upvotes: 0