问题
I've encountered a scenario where the menu item Title specified on the Joomla back-end in Menu Manager overrides the following call: JFactory::getDocument()->setTitle('Custom title')
The document's title becomes 'Custom title' up until the following lines in components/com_content/views/article/view.html.php
:
if (empty($title)) {
$title = $this->item->title;
}
$this->document->setTitle($title);
I assign a new title to the document in my module:
JFactory::getDocument()->setTitle('New title');
How can I stop Joomla from overwriting the article I gave the document in my module?
回答1:
You Can Use Javascript from your module:
Note me Please If This Code Helps you :)
JFactory::getDocument()->addScriptDeclaration("
window.onload=function(){
changeTitle('New Title')
}
function changeTitle(newTitle){
document.title=newTitle;
}
");
来源:https://stackoverflow.com/questions/24865448/menu-item-title-overriding-settitle-in-module