Menu item title overriding setTitle in module

时光怂恿深爱的人放手 提交于 2019-12-10 21:15:38

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!