Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
类型3-覆盖&;在自定义扩展的详细视图上添加元标记(来自tx_metaseo)_Seo_Typo3_Extbase_Typo3 8.x_Typo3 8.7.x - Fatal编程技术网

类型3-覆盖&;在自定义扩展的详细视图上添加元标记(来自tx_metaseo)

类型3-覆盖&;在自定义扩展的详细视图上添加元标记(来自tx_metaseo),seo,typo3,extbase,typo3-8.x,typo3-8.7.x,Seo,Typo3,Extbase,Typo3 8.x,Typo3 8.7.x,我有一个自定义扩展,在记录的详细页上,我想搜索引擎优化皮条客的个人资料网站。我也在使用tx_metaseo 我已经在通过show action更改“title”标签,如下所示: /** * action show * * @param Application $record * @return void */ public function showAction(Application $record=null) { // For the search

我有一个自定义扩展,在记录的详细页上,我想搜索引擎优化皮条客的个人资料网站。我也在使用tx_metaseo

我已经在通过show action更改“title”标签,如下所示:

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

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

}
但是因为我已经安装了tx_metaseo。。。我还得到了generall元标记。因此,在我的扩展的详细信息页面上,我想覆盖它们:

<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="">
。。。或:

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

由于不能覆盖现有的元值,所以需要防止创建默认的元标记

一种常见的方法是打字条件。
您可以通过URL参数标识显示记录详细视图的页面,该参数获取要显示的记录的uid

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

[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]
第一个示例可以通过添加更多条件(假设这些记录的详细视图位于不同的页面上)对多个记录进行增强:

使用生成元标记的扩展,而不选择通过打字脚本控制它,会使整个过程非常复杂

Outlook:使用TYPO3 9处理元标记会更容易


ext:metaseo最简单的操作与手册中提到的类似。
或者使用钩子操作扩展生成的所有值的整个数组


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

谢谢您的评论。我尝试过像[globalVar=TSFE:id=71,GP:tx\u metaseo]这样的条件。。。[globalVar=TSFE:id=71,GP:tx|u metaseo | var=0]。。。[全局]请参见上面的编辑。但它仍然给我元标签。tx\u metaseo的情况如何?回答enhancedHi@PhilippM您的TS条件应该检查您的插件签名,而不是
tx\u metaseo
。如果你的插件签名是extensionkey\u pluginname,那么你的条件应该是
[globalVar=GP:tx\u extensionkey\u pluginname | record>0]
-没有理由将它限制为一个pid,我打赌你希望它在你有一个插件视图的任何地方都能工作。
[globalVar = TSFE:id = 71]
    plugins.tx_metaseo >
[global]   
[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]
[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]