How can I correctly instantiate tx_news by Typoscript - typo3

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.

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

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

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

TYPO3 - typoscript for extension plugin

I would like to execute some typoscript commands only on page with a specific plugin on it :
page.includeCSS { }
page.includeJS { }
lib.my_bloc = COA
etc...
I move my typoscript code into the file typo3conf/ext/my_company_plugin/Configuration/TypoScript/setup.txt but it seems not to work. How to make it work ?
Furthermore, I'm not able to set a default storagepid for my module. I want all new entities to be stored in the same specific folder (uid 184 by the way) but my TS into setup.txt isn't effective and the pid in database is the page the user were on, not the 184.
#constant
module.tx_company_events.persistence.storagePid = 184
#setup
module.tx_company_events.persistence.storagePid = {$module.tx_company_events.persistence.storagePid}
If You want to add typoscript for specific page plugin then you can use typoscript condition like below.
// if get your plugin parameters then below typoscript works
[globalVar = GP:tx_extension_key|var1 > 0]
// write your typoscript
page.includeCSS { }
page.includeJS { }
lib.my_bloc = COA
[end]
// FOr specific pageId
[globalVar = TSFE:id = 10]
page.includeCSS { }
page.includeJS { }
lib.my_bloc = COA
[end]
Also For StoragePid, make sure you included TypoScript from your ext in Root template.

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
}