菜单项标题覆盖setTitle模块中 [英] Menu item title overriding setTitle in module

查看:146
本文介绍了菜单项标题覆盖setTitle模块中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一种情况,其中在菜单管理器的Joomla后端上指定的菜单项标题"将覆盖以下调用:JFactory::getDocument()->setTitle('Custom title')

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')

文档标题变为自定义标题",直到components/com_content/views/article/view.html.php中的以下行:

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');

如何阻止Joomla覆盖我在模块中提供的文章?

How can I stop Joomla from overwriting the article I gave the document in my module?

推荐答案

您可以在模块中使用Javascript:

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;            
        }       
    ");

这篇关于菜单项标题覆盖setTitle模块中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆