简体   繁体   English

Joomla中的自定义SEO文章标题

[英]Custom SEO article title in Joomla

While it's possible to manually enter the full title of a page displaying a category, how would I go about doing the same for an article page in Joomla 2.5? 虽然可以手动输入显示类别的页面的完整标题,但如何在Joomla 2.5中对文章页面执行相同的操作?

The default is to use the article title as the page title, eg "How to care for goldfish", with an option to add the site name. 默认设置是将文章标题用作页面标题,例如“如何照顾金鱼”,并带有添加站点名称的选项。

What I want is to have the title as follows: How to care for goldfish | 我想要的标题是:如何保养金鱼| Fish care guides | 鱼类护理指南| FishSite.com FishSite.com

The obvious solution would be just to put all that in the title of the article, but then I'd have a problem in the "Latest articles" module, it would become unreadable with all the extra text. 显而易见的解决方案是将所有内容放在文章标题中,但随后我在“最新文章”模块中遇到问题,所有其他文本将变得不可读。

How to solve this? 如何解决呢? Plugin, coding, or some clever solution? 插件,编码还是一些聪明的解决方案? It needs to be more or less automatic though, I can access the Joomla database and change each page title manually but that wouldn't be feasible. 不过,它或多或少需要自动执行,我可以访问Joomla数据库并手动更改每个页面标题,但这不可行。 If manual text entry is needed, it has to be in Joomla. 如果需要手动输入文本,则必须在Joomla中。

The plugin system responds to events , so the easiest solution would be a either a Content or System plugin that manipulates the Title by appending the relevant information prior to display. 插件系统响应事件 ,所以最简单的解决方案是Content或System插件,该插件通过在显示之前附加相关信息来操纵Title。

I think with a content plugin you could use the onContentPrepare event to do all the work. 我认为使用内容插件可以使用onContentPrepare事件来完成所有工作。

In rough psuedo code (ie this won't run), I would probably end up with something like this: 在粗糙的伪代码中(即,该代码将无法运行),我可能最终会遇到这样的情况:

public function onContentPrepare($context, &$article, &$params, $page = 0)
{
    // Don't run this plugin when the content is being indexed
    if ($context == 'com_finder.indexer') {
        return true;
    }
    // Perform a sanity check to make sure we're on an article layout

    // Build new title
}

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

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