简体   繁体   English

Joomla 3-使用文章标题作为浏览器页面标题,而不是菜单项标题

[英]Joomla 3 - use article title as Browser Page Title instead of menu item title

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

For eg. 例如。 My Menu item title is 'transmissions' because it's a sub-menu item to 'light duty'. 我的菜单项标题为“ transmissions”,因为它是“ lightty”的子菜单项。 My page title is 'Light Duty Transmissions'. 我的页面标题是“轻型变速器”。 When you browse to the page through the main menu, the <title> tag is 'transmissions' and I need it to be the article title: 'Light Duty Transmissions'. 当您通过主菜单浏览到页面时, <title>标签是'transmissions',我需要将其作为文章标题:'Light Duty Transmissions'。

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. 但是我担心这会在将来尝试更新页面标题时造成混乱。

Thanks, Mel 谢谢,梅尔

You have to make a simple addition to article template. 您必须对文章模板进行简单的添加。

You have to copy: 您必须复制:

/components/com_content/views/article/tmpl/default.php

To the template folder (if doesn't already exist): 到模板文件夹(如果尚不存在):

/templates/*your_template/html/com_content/article/default.php

And add these two lines at the top of the page: 并在页面顶部添加以下两行:

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

Hope this helps 希望这可以帮助

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

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