TYPO3-覆盖和在自定义扩展的详细信息视图上添加meta标签(来自tx_metaseo) [英] TYPO3 - Overriding & adding meta tags (from tx_metaseo) on detail view of custom extension

查看:66
本文介绍了TYPO3-覆盖和在自定义扩展的详细信息视图上添加meta标签(来自tx_metaseo)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自定义扩展名,并且在记录的详细信息页面上我想搜索配置文件站点.我也在使用tx_metaseo.

I have a custom extension and on the detail page of the records I want to seo pimp the profile sites. I'm also using tx_metaseo.

我已经通过如下所示的show动作更改了'title'标签:

I'm already changing the 'title' tag via the show action like this:

/**
 * action show
 *
 * @param Application $record
 * @return void
 */
public function showAction(Application $record=null) {

        // For the search
        $GLOBALS['TSFE']->indexedDocTitle = $record->getName();     
    }   

}

但是由于我已经安装了tx_metaseo ...我也得到了generall元标记.因此,在我的扩展程序的详细信息页面上,我想覆盖它们:

But since I have tx_metaseo installed ... I'm also getting the generall meta tags. So on the detail page of my extension I would like to override them:

<meta name="DCTERMS.title" content="">
<meta name="description" content="">
<meta name="DCTERMS.description" content="">
<meta name="keywords" content="">
<meta name="DCTERMS.subject" content="">

<meta property="og:title" content="">
<meta property="og:type" content="">
<meta property="og:email" content="">

...此外,我想添加/设置:

... in addtion I want to add/set:

<meta property="og:description" content="">

...并且我想考虑一个语言因素(默认/德语/英语)...所以我想添加(对于德语):

... and I want to have a lange consideration (Default/German/English) ... so I would like to add (for German):

<meta http-equiv="Content-Language" content="de" />
<meta name="Language" CONTENT="Deutsch"/>

我该怎么做?

我认为我需要使用挂钩/信号吗? https://docs.typo3.org/typo3cms/extensions/metaseo/DeveloperManual/Index.html#signals 但是如何?

I assume I need to work with Hooks/Signals? https://docs.typo3.org/typo3cms/extensions/metaseo/DeveloperManual/Index.html#signals But how?

这是一个类似的讨论: https://github.com/webdevops/TYPO3-metaseo/issues/477

Here is a similar discussion: https://github.com/webdevops/TYPO3-metaseo/issues/477

我尝试这样做是为了防止tx_metaseo创建的元标记

I tried this to prevent the meta tags created by tx_metaseo

#[globalVar = TSFE:id = 71, GP:tx_metaseo|var = 0]
[globalVar = TSFE:id = 71, GP:tx_metaseo]
    #page.metaseo.meta.og:title >
    #page.metaseo.meta.og:description >
    page.meta.og:title = 
    page.meta.og:description = 
[global]

...或:

[globalVar = TSFE:id = 71]
    plugins.tx_metaseo >
[global]   

推荐答案

,因为您无法覆盖现有的元值,因此需要阻止创建默认的元标记.

as you can not override an existing meta value you need to prevent creating of the default meta tags.

一种常见的方式是打字错误.
您通常可以通过URL参数来标识显示记录详细视图的页面,该参数获取要显示的记录的uid.

One usual way would be a typoscript condition.
You can identify the pages where you show the detail view of your records usually by a URL parameter which gets the uid of the record to be shown.

关于新闻记录,您可以在网站扩展模板中这样做:

Regarding news records you could do it like this in a site extension template:

[globalVar = GP:tx_news_pi1|news > 0]
    // set news-specific meta tags
[else]
    // set default meta tags (based just on the pages record)
[global]

或另一种方式:

// somewhere (site_extension or other specific template):
// set default meta tags (based just on the pages record)


// in the static template of your extension:
[globalVar = GP:tx_news_pi1|news > 0]
    // clear default meta tags (if that is possible) 
    page.meta.og:title >
    page.meta.og:site_name >
    page.meta.og:description >
    page.meta.og:image >

    // or deactivate the extension for generating the default meta tags
    // maybe something like
    plugins.tx_metatagsgenarator >

    // finaly: set news-specific meta tags
     :
[global]

只需添加更多条件(假设这些记录的详细信息视图在不同的页面上),就可以增强多个记录的第一个示例:

The first example can be enhanced for multiple records just by adding more conditions (assuming the detail views of these records are on differnt pages):

[globalVar = GP:tx_news_pi1|news > 0]
    // set news-specific meta tags
[globalVar = GP:tx_myext|myrec_uid > 0]
    // set myext-specific meta tags
[else]
    // set default meta tags (based just on the pages record)
[global]

使用生成meta标签的扩展程序,如果没有选项,则可以通过印刷文字来控制它,这会使整个过程变得非常复杂.

Using extensions which generate the meta tags whithout option to control it by typoscript would make the whole process very complicated.

Outlook:使用TYPO3 9可以更轻松地处理元标记.

Outlook: Handling meta tags will be easier with TYPO3 9.

用于ext:metaseo的最简单的操作类似于 stdWraps .
或使用挂钩操作扩展程序生成的所有值的整个数组.

The easiest manipulation for ext:metaseo looks like the stdWraps mentioned in the manual.
Or use the hooks to manipulate the whole array of all the values the extension is generating.

并没有真正提示如何增强扩展功能以获取更多记录.因为您不仅需要为详细视图添加元标记,还需要做更多的事情:您需要增强生成的站点地图.扩展作者也许需要一些冲动来增强有关如何为自己的记录添加元信息的信息的手册.

in the extension manual there are no real hints how to enhance the features of the extension for additional records. as you need to do more than just ethe meta-tags for the detail views: you need to enhace the generated sitemap. Maybe the extension author(s) need some impulse to enhance the manual with the informations how to add meta information for own records.

这篇关于TYPO3-覆盖和在自定义扩展的详细信息视图上添加meta标签(来自tx_metaseo)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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