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. Nevertheless you can quite easly achieve that by integrating plugin via 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
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:
<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.
Of course you need to specify startingpoint
and templateLayout
to match your specific TYPO3 configuration.