TYPO3 - tx_news - Show related articles on detail page except current article - typo3

On the detail page of a tx_news record I also provide 'related articles' of the current article/record ... with the below snippet. But in the suggested 'related articles' the current record is also provided. How can I exclude the current article from the suggested list?
Typoscript:
lib.relatedByFirstCategory.articles = USER
lib.relatedByFirstCategory.articles {
userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
extensionName = News
pluginName = Pi1
vendorName = GeorgRinger
switchableControllerActions {
News {
1 = list
}
}
settings < plugin.tx_news.settings
settings {
#relatedView = 1
detailPid = 97
useStdWrap := addToList(categories)
categories.current = 1
categoryConjunction = or
overrideFlexformSettingsIfEmpty := addToList(detailPid)
startingpoint = 96
templateLayout = 4
hidePagination = 1
# added
excludeAlreadyDisplayedNews =1
}
}
News Detail.html
<!-- related articles -->
<f:if condition="{newsItem.firstCategory}">
<f:cObject typoscriptObjectPath="lib.relatedByFirstCategory.articles">{newsItem.firstCategory.uid}</f:cObject>
</f:if>
</f:if>
Source: https://docs.typo3.org/typo3cms/extensions/news/stable/singlehtml/Index.html#show-news-items-with-same-category-in-detail-html

excludeAlreadyDisplayedNews is your friend. Look here: https://docs.typo3.org/typo3cms/extensions/news/stable/singlehtml/Index.html#excludealreadydisplayednews

Related

In typo3 news typoscript, how do I set startingpoint to current page ID?

In old versions of typo3 this code worked but in latest version v11 it doesn't.The problem is that "this" value defined as "startingpoint" doesn't return current page id anymore.
lib.pageNews = USER
lib.pageNews {
userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
extensionName = News
pluginName = Pi1
vendorName = GeorgRinger
switchableControllerActions {
News {
1 = list
}
}
settings < plugin.tx_news.settings
settings {
startingpoint = this
recursive = 99
templateLayout = 100
hidePagination = 0
#limit = 10
detailPid = 1075
list.paginate.itemsPerPage = 20
}
}
What is the "new" way to achieve this?
I tried to call that id in multiple ways like: TSFE:id, lib.currentPageId, TSFE:page|id, TSFE:page|uid, {TSFE:uid}, {TSFE:id}, getTSFE().id, .....
That is possible by using useStdWrap.
lib.pageNews {
settings {
useStdWrap = startingpoint
startingpoint {
data = TSFE:id
}
}
}
Source: https://github.com/georgringer/news/issues/542

Generate speaking url for tx_news using typoscript in TYPO3 9.5.8

I use TYPO3 v 9.5.8 together with tx_news (7.2.0).
I really like the new TYPO3 implemented speaking url generation.
I already configured it to generated speaking urls and configurated it to generate speaking urls for tx_news too, both is working fine. But I also want to show the last three news entries in page footer.
My solution was to generate them in typoscript setup and pass them to fluid template. My current typoscript code looks like this:
news = CONTENT
news {
table = tx_news_domain_model_news
select {
pidInList = 24
max = 3
orderBy = datetime DESC
}
renderObj = COA
renderObj {
1 = TEXT
1.field = datetime
1.strftime = %d. %B %Y
1.wrap = <p>|</p>
2 = TEXT
2 {
field = title
typolink {
parameter = 26
parameter.override.field = internalurl
useCacheHash = 0
additionalParams.wrap = &tx_news_pi1[news]=|
additionalParams.field = uid
}
}
}
renderObj.wrap = <div class="header-news-item">|</div>
}
At least this works. But since I use additionalParams.wrap to append the id of the news entry, the generated url looks like this:
Lorem ipsum dolor sit
I want to url to look like this:
Lorem ipsum dolor sit
This is the same as tx_news list view generates for redirecting to detail view.
Does somebody got an idea how this is possible?
I guess you are missing action & controller in generating your TypoScript.
With the hint from Georg Ringer, I got it working.
Here's the working example, beginning with TypoScript:
news = CONTENT
news {
table = tx_news_domain_model_news
select {
pidInList = 24 // Page ID of the page that contains the news entries.
max = 3
orderBy = datetime DESC
}
renderObj = COA
renderObj {
1 = TEXT
1.field = datetime
1.strftime = %d. %B %Y
1.wrap = <p>|</p>
2 = TEXT
2 {
field = title
typolink {
parameter = 26 // Page ID of the page that displays the detail view.
parameter.override.field = internalurl
useCacheHash = 0
additionalParams.wrap = &tx_news_pi1[action]=detail&tx_news_pi1[controller]=News&tx_news_pi1[news]=|
additionalParams.field = uid
}
}
}
renderObj.wrap = <div class="header-news-item">|</div>
}
To get it working, you have to enable speaking urls for tx_news too, of course. You can do this since TYPO3 9 LTS by adding this to the site yaml config file:
routeEnhancers:
News:
type: Extbase
extension: News
plugin: Pi1
routes:
- routePath: '/{news-title}'
_controller: 'News::detail'
_arguments:
news-title: news
aspects:
news-title:
type: PersistedAliasMapper
tableName: tx_news_domain_model_news
routeFieldName: path_segment
This is descripted here.

How can I correctly instantiate tx_news by Typoscript

I need to create a instance of tx_news via Typoscript, but when I set startingpoint or limit settings, the plugin is not show in frontend; without these options it dislpays all storage news.
I have followed documentation in https://docs.typo3.org/typo3cms/extensions/news/AdministratorManual/BestPractice/IntegrationWithTypoScript/Index.html#add-news-by-typoscript and other pages. I am using TYPO3 8.7 and PHP 7.1
#Remove content in section
page.10.variables.noticiasGNFA >
lib.news = USER
lib.news {
userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
extensionName = News
pluginName = Pi1
vendorName = GeorgRinger
switchableControllerActions {
News {
1 = list
}
}
settings < plugin.tx_news.settings
settings {
detailPid = 515
overrideFlexformSettingsIfEmpty := addToList(detailPid)
orderBy = datetime
listPid = 151
backPid = 151
disableOverrideDemand = true
templateLayout = 4
#startingpoint = 318
#limit =3
}
}
#Set new tx_news plugin in section
page.10.variables.noticiasGNFA < lib.news
When the comment of any options with hashtag is removed, it does not work. Not display, not show some exception.
If you are using a Fluid template, you can use the <f:cObject typoscriptObjectPath="lib.news"/> anywhere.
Hope it helps.

How to communicate two plugins of News for Typoscript

I have to show in my single page: the single and the list of News with the same categories of single new. I have two plugins in my backend page and have tried to assign the categories of single to the list for typoscript, but i could not do it.
This is the code, i used page.x for debug and catch values:
page.100 = TEXT
page.100.data = GP:tx_ttnews|tt_news
page.100.wrap = The single tt_news id is: |
page.100.data = GP:tx_ttnews|cat
page.100.wrap = The category of single is: |
page.110 = TEXT
page.110
{
value = { register:newsCategoryUid }
insertData = 1
wrap = - Categories: |
}
plugin.tt_news
{
categorySelection = { register:newsCategoryUid }
#show only selected categories
categoryMode = 1
}
It's not fully visible what you're trying. I think the best way should to put the cat value inside a temp object. Do you have the plugins inserted by TypoScript or as Content Element? You are using tt_news not news by georg ringer right?
temp.tx_news_catId = TEXT
temp.tx_news_catId.data = GP:tx_ttnews|cat
temp.tx_news_catId.intval = 1
page.110 < temp.tx_news_catId
page.110.wrap = Category: |
plugin.tt_news
{
categorySelection < temp.tx_news_catId
# you need to use data not categorySelection = {...} <- that should
# only work on constants
# but only works if categorySelection capabilities
#categorySelection.data = register:newsCategoryUid
#show only selected categories
categoryMode = 1
}
(Untested TypoScript)
hope this helps you a little bit
PS: Have you checked whether categorySelection has stdWrap capabilities?
I don't really get what you want to do, maybe this helps a bit:
If you want to show in the detail action articles with the same category as the current one, you can use a snippet like this one:
Add this to the Detail.html which will pass the first category uid to the TypoScript object lib.tx_news.relatedByFirstCategory.
<f:if condition="{newsItem.firstCategory}">
<f:cObject typoscriptObjectPath="lib.tx_news.relatedByFirstCategory">{newsItem.firstCategory.uid}</f:cObject>
</f:if>
and the TS:
lib.tx_news.relatedByFirstCategory = USER
lib.tx_news.relatedByFirstCategory {
userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
extensionName = News
pluginName = Pi1
vendorName = GeorgRinger
switchableControllerActions {
News {
1 = list
}
}
settings < plugin.tx_news.settings
settings {
relatedView = 1
detailPid = 31
useStdWrap := addToList(categories)
categories.current = 1
categoryConjunction = or
overrideFlexformSettingsIfEmpty := addToList(detailPid)
startingpoint = 78
}
}
I have taken this from the manual.

tx_news and roq_newsevent: integrate plugin via TypoScript

I am upgrading tt_news + mbl_newsevent to their successors tx_news + (probably) roq_newsevent.
I am still missing out on how to access roq_newsevent data in a template when integrating (trying to) it via TypoScript.
Another community member has asked the same question on TYPO3 forge https://forge.typo3.org/issues/61060 before, but no answer.
I would expect it's just extbase basics, I haven't seen a plugin that can only be used via flexform, is it?
EDIT (returns no news):
temp.newslist = USER
temp.newslist {
userFunc = tx_extbase_core_bootstrap->run
extensionName = News
pluginName = Pi1
switchableControllerActions {
News {
1 = eventList
}
}
settings < plugin.tx_news.settings
settings.startingpoint = {$pidRecords}
settings.recursive = 1
settings.detailPid = {$pidDetail}
view =< plugin.tx_news.view
}