2

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.

Bernd Wilke πφ
  • 10,390
  • 1
  • 19
  • 38
josias
  • 1,326
  • 1
  • 12
  • 39

2 Answers2

2

You missed to declare the pathes to your version of the templates.

you have two ways:

  1. use the constants ext:news provides you and inserts automatically in the TS setup

  2. 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.

Bernd Wilke πφ
  • 10,390
  • 1
  • 19
  • 38
  • 1
    I've used method 2 you posted. I got it to work thank you very much, though two more questions, in the first method you used the constant from ext:news not ext:myextension. Doesn't it make more sense to put that into my extension, since when news updates, my changes will get lost I thought. My other question, what exactly are the difference between using setup and constants, what are the benefits for each? – josias May 25 '18 at 07:47
  • If you use constants the constants are stored in a template record. the constants declaration in ext:news is not modified. you can declare the constants in your typoscript, but you need to use the names(/paths) from ext:news, as they are used with the exact name in the TS setup from ext:news. – Bernd Wilke πφ May 25 '18 at 08:21
  • 1
    **NEVER EVER** change anything in files beyond `typo3conf/ext/` which do not belong to your own extensions! – Bernd Wilke πφ May 25 '18 at 08:23
0
  • 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.

Heinz Schilling
  • 2,177
  • 4
  • 18
  • 35