简体   繁体   English

TYPO3 tx_news-如何按类别显示相关新闻?

[英]TYPO3 tx_news - How to show related news by category?

is there an easy way to show related news by category in the news detail template? 有没有一种简单的方法可以在新闻详细信息模板中按类别显示相关新闻? For a single news item I want to show three related news by category. 对于单个新闻,我想按类别显示三个相关新闻。

Ralf 拉尔夫

News extension does not offer such configuration for front-end plugin in TYPO3 back-end. 新闻扩展没有为TYPO3后端中的前端插件提供这种配置。 Nevertheless you can quite easly achieve that by integrating plugin via TypoScript. 不过,您可以通过TypoScript集成插件来轻松实现这一目标。 You'll find more about it in official documentation for news extension. 您可以在新闻扩展的官方文档中找到有关它的更多信息。 Anyway, this snippet might do the trick for you. 无论如何,此代码片段可能会帮您解决问题。

Step 1) Integrate news extension via TypoScript 步骤1)通过TypoScript集成新闻扩展

lib.newsRelatedByFirstCategory = USER
lib.newsRelatedByFirstCategory {
    userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
    extensionName = News
    pluginName = Pi1
    vendorName = GeorgRinger

    switchableControllerActions {
        News {
            1 = list
        }
    }

    settings < plugin.tx_news.settings
    settings {
        excludeAlreadyDisplayedNews = 1
        templateLayout = 201
        relatedView = 1
        limit = 6
        useStdWrap := addToList(categories)
        categories.current = 1
        categoryConjunction = or
        overrideFlexformSettingsIfEmpty := addToList(detailPid)
        startingpoint = 59
    }
}

Step 2) Display news plugin via cObject in your news' extension template: 步骤2)在您的新闻扩展模板中通过cObject显示新闻插件:

<f:cObject typoscriptObjectPath="lib.newsRelatedByFirstCategory">{newsItem.firstCategory.uid}</f:cObject>

It will make an instance of news plugin and display 6 news records from the first category to which belongs currently displayed news. 它将成为新闻插件的实例,并显示属于当前显示新闻的第一类的6条新闻记录。

Of course you need to specify startingpoint and templateLayout to match your specific TYPO3 configuration. 当然,您需要指定startingpointtemplateLayout以匹配您特定的TYPO3配置。

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

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