我有一个现有模块,我使用 {loadposition custom_position} 从一篇文章中显示它。文章链接到菜单项。我希望能够从此模块设置自定义页面标题,覆盖菜单项设置的页面标题。
我试过用
$document = JFactory::getDocument();
$document->setTitle('Set your title here');
但它没有设置页面标题。
是否可以在模块内设置页面标题,还是只能在组件内完成。
最佳答案
你写的代码是正确的,但是可能其他模块/插件在你改了之后改了标题。
您可能希望在设置标题后立即回显,例如
$document = JFactory::getDocument();
$document->setTitle('Set your title here');
echo "<h1>" . JFactory::getDocument()->getTitle() . "</h1>";
如果这是正确的,你需要寻找其他模块/插件来改变它。
关于joomla - 在 Joomla! 中设置页面标题3 来自模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31454079/