Menu item title overriding setTitle in module

2019-07-02 03:51发布

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条回答
贪生不怕死
2楼-- · 2019-07-02 04:39

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;            
        }       
    ");
查看更多
登录 后发表回答