在 Joomla 中设置页面标题!3 来自一个模块 [英] Set page title in Joomla! 3 from a module

查看:11
本文介绍了在 Joomla 中设置页面标题!3 来自一个模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个现有模块,我使用 {loadposition custom_position} 从文章中显示该模块.文章链接到菜单项.我希望能够从此模块设置自定义页面标题,覆盖菜单项设置的页面标题.

I have an existing module, which I display from an article by using {loadposition custom_position}. The article is linked to a menu item. I want to be able to set a customized page title from this module, overwriting the page title set by the menu item.

我尝试使用

$document = JFactory::getDocument();
$document->setTitle('Set your title here');

但是它没有设置页面标题.

But it does not set the page title.

是否可以在模块内设置页面标题,或者只能在组件内设置.

Is it possible to set the page title from within a module, or can it only be done within a component.

推荐答案

你写的代码是正确的,但是可能其他模块/插件在你改了之后改了标题.

The code you wrote is correct, but maybe other modules / plugins are changing the title after you change it.

您可能想在设置后立即回显标题,例如

You may want to echo the title immediately after you set it, e.g.

$document = JFactory::getDocument();
$document->setTitle('Set your title here');
echo "<h1>" . JFactory::getDocument()->getTitle() . "</h1>";

如果这是正确的,您需要寻找稍后更改它的其他模块/插件.

If that is correct, you need to look for other modules / plugins that change it later.

这篇关于在 Joomla 中设置页面标题!3 来自一个模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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