TYPO3 tx_news extension not using override template - typo3

I have two sites using the tx_news extension. As far as I can tell they are set up identically. On site A I have added a new List.html partial and it works as expected. On site B however it is completely ignoring my List override.
I have triple checked the file path to make sure the typoscript points to the right place but it still uses the default. What could be wrong here?
plugin.tx_news {
view {
templateRootPaths >
templateRootPaths {
0 = EXT:news/Resources/Private/Templates/
1 = fileadmin/templates/example/news/Templates/
}
partialRootPaths >
partialRootPaths {
0 = EXT:news/Resources/Private/Partials/
1 = fileadmin/templates/example/news/Partials/
}
layoutRootPaths >
layoutRootPaths {
0 = EXT:news/Resources/Private/Layouts/
1 = fileadmin/templates/example/news/Layouts/
}
}
}

To make it work as expected I would do the following:
1) Copy the three folders from ext/news/Resources/Private/Templates, Partials, Layouts to fileadmin/templates/example/news
(I believe you have already done that)
2) Then place this in to your template provider or page typoscript constants:
plugin.tx_news {
view {
templateRootPath = fileadmin/templates/example/news/Templates/
partialRootPath = fileadmin/templates/example/news/Partials/
layoutRootPath = fileadmin/templates/example/news/Layouts/
}
}
Now the news extension will use the Template files placed in fileadmin/
Next step would be to add some pageTSConfig inside your root pages properties in case you need more flexibility. For example like this:
tx_news.templateLayouts {
1 = Special List Item
2 = Special Detail Layout
}
That allows you to select one of these template layouts in your news plugin and to use conditions in your template file:
<f:if condition="{settings.templateLayout} == 1">
<f:then>
<!-- markup for a special list item -->
</f:then>
<f:else>
<!-- markup for another list item -->
</f:else>
</f:if>

Your script looks good. When something like this happens in TYPO3 there is an option to check whatever your TypoScript valid or this changes are really added into the right place.
Go into the BE, select the Template module and with the TypoScript Object Browser you can see if in your Setup every changes are there or not. (Or if you may have a syntax error)

Related

TYPO3 render Event from typoscript and Fluid template

In TYPO3 10.4.8 I have the following page tree:
root
1level: Events
2level: Event A, Event B, Event C, ... and so ...
What I want to do in page Events is to render all subpages title, using FLUIDTEMPLATE.
So in the template of page Events I wrote
lib.EventContent = COA
lib.EventContent {
10 = COA
10{
table = pages
select {
orderBy = sorting
pidInList = this
}
}
}
and in the layout file
<f:for each="lib.EventContent" as="event" >
<p>event: {event.title}</p>
</f:for>
This doesn't work. Typo give me this error:
The argument "each" was registered with type "array", but is of type "string" in view helper "TYPO3Fluid\Fluid\ViewHelpers\ForViewHelper".
In addition, I also tried to change COA with CONTENT, in all possible combination (COA-CONTENT / CONTENT-COA / CONTENT-CONTENT)
What's wrong? is something that I cannot do?
Thanks all
The TypoScript should look something like this:
lib.EventContent = CONTENT
lib.EventContent {
table = pages
select {
orderBy = sorting
pidInList = this
}
}
But there is a much easier solution. TYPO3 already brings a content element "Subpages" which renders a menu of all subpages of a selected page:
This is done via Fluid Styled Content and TypoScript. Please check this file for details:
typo3/sysext/fluid_styled_content/Configuration/TypoScript/ContentElement/MenuSubpages.typoscript
A solution for you might look like this (untested):
lib.EventContent < tt_content.menu_subpages
lib.EventContent {
dataProcessing {
10 {
special >
}
}
}
It's also a good idea to have a look in all the TypoScript files in the Fluid Styled Content extension to get more inspiration.

How to include Header.html partial in TYPO3 ver 9

I want to change the Layout of my Headers in TYPO3. There is a post about this but this but I cant get it to work and that post is 2 years old. With TYPO3 most stuff is outdated quite quickly. This is the post.
Additionally I looked at this article. I know it is in German, maybe it helps anyways.
So I copied the Header.html from the TYPO3 system files, put it in a directory under fileadmin and tried to link to that directory.
fileadmin/.../Partials/Header/Header.html
In the Template setup i added the partialRootPath.
page = PAGE
page {
shortcutIcon = fileadmin/sitedesign/Resources/Private/Templates/Vave/img/Favicon.ico
10 = FLUIDTEMPLATE
10.file = fileadmin/sitedesign/Resources/Private/Templates/Vave/Contact/index.html
10.partialRootPath {
20 = fileadmin/Resources/Private/Partials
}
includeCSS {
contactFile1 = fileadmin/sitedesign/Resources/Private/Templates/Vave/Contact/css/Contact.css
}
}
In Header.html I created an additional case to check if it was working.
<f:case value="7">
<p class="{positionClass}">
<f:link.typolink parameter="{link}">{header}</f:link.typolink>
</p>
</f:case>
I then added that new case in the Page Resources to the TSConfig.
TCEFORM.tt_content.header_layout {
addItems.7 = Name1
}
Changing the content of the Header.html file in the TYPO3 system files works the way I expected it to, so I am quite sure that I understand the basic functionality. The TSConfig part works as well, because I can select "Name1" in the Header Layout Type field.
But no matter what part in the fileadmin Header.html version I change, nothing happens. I checked the path to that Partials folder and the spelling of everything a million times, so I do not think that is the issue either.
Of course I could just change the system file Header.html but that seems wrong on a lot of levels.
Thank you for any help.
Don't mix different usages of fluid!
You want to change the header partial of your content elements.
But you add the new partial to the fluid of page rendering.
if you use FSC (Fluid Styled Content) your additional partial path should go here:
lib.contentElement {
partialRootPaths {
10 = fileadmin/Resources/Private/Partials
}
}
breaking change: lib.contentElementinstead of lib.fluidContent
Additional advices:
be carefull with the names: aside from partialRootPaths there sometimes exist partialRootPath (without s in the end), which is not an object array. That enables you to set only one path (not the usual path list with priority) and which has priority over settings in partialRootPaths if both exist.
separate the different fluid usages!
Give them different paths. There are multiple ways. I prefer:
each extension gets it's own three folders in a folder named for the extension.
And also separate the page rendering and CEs (Content Elements). Your own CEs might be considered as part of the extension 'FSC'.
use a site extension.
All configuration goes into that extension: typoscript, templates, viewhelpers, TCA, ...
That is the basic configuration for that site, but also the additional configuration/ adaption for the used extensions.
May this code will help you!!
page = PAGE
page {
shortcutIcon = fileadmin/sitedesign/Resources/Private/Templates/Vave/img/Favicon.ico
10 = FLUIDTEMPLATE
10 {
templateName = TEXT
templateName {
cObject = TEXT
cObject {
data = levelfield:-2,backend_layout_next_level,slide
override.field = backend_layout
required = 1
case = uppercamelcase
split {
token = pagets__
cObjNum = 1
1.current = 1
}
}
ifEmpty = Innenseite
}
#templateName=TEXT
# templateName.value=index
layoutRootPaths {
20 = your layoutRootPaths
}
partialRootPaths {
20 = your partialRootPath
}
templateRootPaths {
20 = your templateRootPath
}
}
includeCSS {
contactFile1 = fileadmin/sitedesign/Resources/Private/Templates/Vave/Contact/css/Contact.css
}
}
Make sure header included properly in main template

Override a Fluid Template from another extension

I'm working on a TYPO3 webpage for a magazine. Therefore I'm using the extension "news" or "tx_news".
Everything works fine, except that I'm confused how and where to override the given fluidtemplates from the news extension. For the webpage I'm using an own extension to keep all the backend layouts and fluid templates stored, I would like to include an own fluidtemplate for the News as well inside my extension, so the changes I make won't get overriden when I update the news extension of course.
I've tried just copy pasting the fluid templates from the news into my extension with the hope that they get overriden, since my extension has the highest priority in the backend. Also I found on the documentation that I should add the following lines into my TS setup:
plugin.tx_news {
view {
templateRootPaths >
templateRootPaths {
0 = EXT:news/Resources/Private/Templates/
1 = fileadmin/templates/ext/news/Templates/
}
partialRootPaths >
partialRootPaths {
0 = EXT:news/Resources/Private/Partials/
1 = fileadmin/templates/ext/news/Partials/
}
layoutRootPaths >
layoutRootPaths {
0 = EXT:news/Resources/Private/Layouts/
1 = fileadmin/templates/ext/news/Layouts/
}
}
}
I have added those lines at the bottom in the setup.txt of my own extension with customized paths of course and it didn't work either.
I appreciate all the help.
You missed to declare the pathes to your version of the templates.
you have two ways:
use the constants ext:news provides you and inserts automatically in the TS setup
add some lines direct to the plugin configuration.
As you use an page extension for all configuration you would avoid the TS constant editor or use it only to identify the names of the constants.
// Path constants from ext:news:
plugin.tx_news {
view {
layoutRootPath = EXT:yourextension/Resources/Private/News/Layouts/
partialRootPath = EXT:yourextension/Resources/Private/News/Partials/
templateRootPath = EXT:yourextension/Resources/Private/News/Templates/
}
}
Anyway you should end up with a TS like this (inspect with TSOB):
plugin.tx_news {
view {
templateRootPaths {
0 = EXT:news/Resources/Private/Templates/
1 = EXT:yourextension/Resources/Private/News/Templates/
}
partialRootPaths {
0 = EXT:news/Resources/Private/Partials/
1 = EXT:yourextension/Resources/Private/News/Partials/
}
layoutRootPaths {
0 = EXT:news/Resources/Private/Layouts/
1 = EXT:yourextension/Resources/Private/News/Layouts/
}
}
}
If you use method 2 you could use higher values to give your templates higher priority - in case multiple extensions and template replacements are active.
This configures the pathes for the layouts, partials and templates you are overriding:
Resources
+- Private
+- News
+- Layouts
+- Partials
+- Templates
in your extension.
Don't use the TS from your question (even if it comes from the original manual.)
It deletes the predefined pathes. (Lines 3,8,13). This might fail after an update where the internal pathes have changed.
Copy only templates from EXT:news in your extension which you
want to change. Your example TypoScript works as fallback and templates missed in 1 are searched in 0.
Overwrite only TypoScript that you want to change.
Then use TypoScript Object Browser and check the TypoScript setup for
plugin.tx_news.view...
If you don't see right paths the order of TypoScript loading must be
changed.

TYPO3 Custom Menu Element

I am trying to create a custom menu element by using this in the Page TSConfig:
TCEFORM.tt_content {
menu_type.addItems.101 = My Menu
}
And this in Setup:
temp.my_menu = HMENU
temp.my_menu {
special = list
special.value.field = pages
1 = TMENU
1 {
wrap = <ul> | </ul>
NO = 1
NO.wrapItemAndSub = <li>|</li>
}
}
tt_content.menu.20.101 < temp.my_menu
But I get 'Oops, an error occurred!' where the menu should be.
It will render fine if I remove the Fluid includes in the template but then all the other content elements give errors.
Is there any way to have a typoscript menu element at the same time as fluid styled content?
Or if I really have to, how do I add a custom fluid menu template?
You need to move the line with the copy operation down to the bottom, otherwise the configuration is not copied, because it is not there yet.
The exception happens, because there is no rendering definition for the menu (because you never copied the configuration).
To see the real error instead of the exception, switch to the development preset in the install tool oder add the following line to your TS setup:
config.contentObjectExceptionHandler = 0
I noticed this :
TCEFORM.tt_content {
menu_type.addItems.101 = My Menu
}
as far as I know should be this :
TCEFORM.tt_content.menu_type {
types {
menu{
addItems {
101 = My Menu
}
}
}
}
I had to 'tweak' the special menus (typo3 7.6) and this worked:
Add special menu and add class="active" in TYPO3

TYPO3 CMS 7 tt_content layouts

I set up my own tt_content layout in TSconfig like
TCEFORM.tt_content.layout.removeItems = 1,2,3
TCEFORM.tt_content.layout.addItems.100 = Green Box
and added the class definition to my typoscript setup like
# Layout Green Box (100)
tt_content.stdWrap.innerWrap.cObject{
100=<tt_content.stdWrap.innerWrap.cObject.default
100.15.value = greenbox
}
in TYPO3 CMS 7.6.9. But it nothing happens in the frontend. The Layout "Green Box" appears in the Appearance > Layout dropdown but the class does not.
Did I something wrong or is there a new way since the fluid layouts in 7+ version?
In fact it needs to be defined in your own fluid template.
So what you do is to copy the private folders of fluid_styled_content to your own private folder of your distribution and added some lines to your typoscript constants like
styles.templates {
templateRootPath = {$resDir}/Private/Tt_content/Templates
partialRootPath = {$resDir}/Private/Tt_content/Partials
layoutRootPath = {$resDir}/Private/Tt_content/Layouts
}
In my case I edit the second line of Textmedia.html to
<div id="c{data.uid}" {f:if(condition: '{data.layout} == 100', then: 'class="greenbox"')}>
and et voila it works fine.
A little late, but somebody might still find this useful.
If you're using css_styled_content, then yes, it changes slightly in new versions.
Basically the structure looks now some like this:
stdWrap.innerWrap.cObject.[default|NN] {
# 10 - OPEN TAG
10.cObject.default.value = <div id="c{field:uid}"
# 20 - CLASS
20.10.value = csc-default
# 30 - CLOSE TAG
30.cObject.default.value = >|</div>
}
Differences between versions:
# overwrite basic settings for selected frame:
stdWrap.innerWrap.cObject.[NN (layout number or default)]
# for open tag: instead of NN.10.value (default.10.value) use: NN.10.cObject.default.value (default.10.cObject.default.value)
# for class: instead of NN.15.value (default.15.value) use: NN.20.10.value (default.20.10.value)
# for close tag: instead of NN.30.value (default.30.value) use: NN.30.cObject.default.value (default.30.cObject.default.value)
So in asked case it will be like this:
# Layout Green Box (100)
tt_content.stdWrap.innerWrap.cObject{
100 =< tt_content.stdWrap.innerWrap.cObject.default
100.20.10.value = greenbox
}