简体   繁体   English

Joomla 3-使用类别标题作为带有菜单项标题的“浏览器页面标题”

[英]Joomla 3 - use category title as Browser Page Title with the menu item title

I'm using Joomla 3.4.8, and I have all of my pages linked to menu items. 我正在使用Joomla 3.4.8,并且所有页面都链接到菜单项。 I can't figure out how to get the menu item title to show in the <title> tag of the page, rather than only the article title. 我不知道如何使菜单项标题显示在页面的<title>标记中,而不仅仅是文章标题。

For eg. 例如。 My Menu item title is 'test', when I press the button it shows test but in that menu item there are many articles. 我的菜单项标题为“测试”,当我按下按钮时,它显示测试,但该菜单项中有很多文章。 when i click on the article in the test page. 当我单击测试页中的文章时。 It only shows the article name and not the menu item. 它仅显示商品名称,而不显示菜单项。 What i want is that it shows the article name + the menu item. 我想要的是它显示文章名称+菜单项。

I know that I can change each 'Browser Page Title' setting for each menu item and individually override the menu item title. 我知道我可以更改每个菜单项的每个“浏览器页面标题”设置,并分别覆盖菜单项标题。 But I'm worried this will create confusion in the future when trying to update page titles. 但是我担心这会在将来尝试更新页面标题时造成混乱。

something like this source but with the menu item. 类似于此源,但带有菜单项。

<?php $document=& JFactory::getDocument();
$document->setTitle( $this->item->title ); ?>

You can retrieve current active menu item and use the parameters that you need with JApplication with this code: 您可以使用以下代码来检索当前的活动菜单项,并在JApplication中使用所需的参数:

$active_menu = JFactory::getApplication()->getMenu()->getActive();

Then set the title as you need: 然后根据需要设置标题:

JFactory::getDocument()->setTitle($active_menu->title." - ".$this->item->title);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM