简体   繁体   English

TYPO3更改指定的tt_news类别中的元值

[英]TYPO3 change meta value in specified tt_news category

I have a question about tt_news and SEO. 我对tt_news和SEO有疑问。 I would like to change some meta value in news from specified category. 我想更改指定类别新闻中的一些元值。 I try with this code but it didn't work: 我尝试使用此代码,但是没有用:

[globalVar = GP:tx_ttnews|tt_news > 0] && [globalVar = GP:tx_ttnews|cat = 13]
   page = PAGE
   page.meta.robots = noindex
[global]

Any suggestion? 有什么建议吗?

The condition [globalVar = GP:param = foo] checks if $_GET or $_POST arrays (in this order) contains the param with value foo , but it soen't check the record for used categories, therefore you need to write custom condition ( reference ) into typo3conf/AdditionalConfiguration.php (mandatory location for TYPO3 6.x! in 4.x that would be common typo3conf/localconf_local.php ) which will check if there's param with single news and then will check tt_news_cat_mm table for relations between News and Category, ready to use sample is: 条件[globalVar = GP:param = foo]检查$_GET$_POST数组(按此顺序)是否包含值为fooparam ,但是它不会检查所用类别的记录,因此您需要编写自定义条件( 参考 )到typo3conf/AdditionalConfiguration.php (在4.x中为TYPO3 6.x!的强制位置,这是常见的typo3conf/localconf_local.php ),它将检查是否存在单个新闻的参数,然后将检查tt_news_cat_mm表之间的关系新闻和类别,准备使用的示例是:

/** For ext:tt_news only! (not for ext:news) */
function user_ttNewsInCat($catUid) {
    $newsParams = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('tx_ttnews');

    // If news is in params then check categories, otherwise skip it
    if (!is_null($newsParams) && is_array($newsParams) && intval($newsParams['tt_news']) > 0) {
        $newsUid = intval($newsParams['tt_news']);
        $matchesInMM = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'tt_news_cat_mm', "uid_local={$newsUid} AND uid_foreign={$catUid}");

        if (count($matchesInMM)>0) return TRUE;
    }

    return FALSE;
}

And its usage in typoscript is: 它在打字稿中的用法是:

[userFunc = user_ttNewsInCat(13)]
  page.meta.robots = noindex
[end]

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

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