Search code examples
typo3typo3-extensions

Override TYPO3 templates


I have a TYPO3 website that is built on a sitepackage that extends bootstrap_package. I need to add more templates and design changes to the sitepackage, so I created a new extension. When I want to override the templates from sitepackage with the templates from my new extension, they all get overridden, and I get errors on the pages that used templates from the sitepackage. Is there a way to load all templates, from the initial bootstrap_package, my sitepackage, and the new extension?

This is from the constants.txt of the sitepackage (example_theme), where it extends bootstrap_package:
constants.txt of the sitepackage example_theme , constants.txt of the sitepackage example_theme

and this is how I am trying to override it with my new extension: constants.typoscript of my new extension constants.typoscript of my new extension and setup.txt of the sitepackage example_theme setup.txt of the sitepackage example_theme

If I do this, then in the backend I can see that example_theme is not loaded:
backend setup backend setup

The pages that used templates from the sitepackage example_theme give me this error:
error on pages that use templates from example_theme error on pages that use templates from example_theme


Solution

  • Either you have the wrong loading order of the extensions, or there is an extension not loaded.

    Especially if you use only constants to define the paths you will miss a definition as only one constant (per path) is inserted.

    In your case you should not use constants in your extension new_extension but set the value 2 in the setup immediately.

    page {
      10 {
        TemplateRootPaths.2 = EXT:new_extension\Resources\Private\Templates\Page\
        PartialRootPaths.2 = EXT:new_extension\Resources\Private\Partials\Page\
        LayoutRootPaths.2 = EXT:new_extension\Resources\Private\Layouts\Page\
      }
    }
    

    in this way you should end up with 3 values for each path.
    (example just for templates:)

    :
    [templateRootPaths]
       [0] = EXT:bootstrap_package\Resources\Private\Templates\Page\
       [1] = EXT:example_theme\Resources\Private\Templates\Page\
       [2] = EXT:new_extension\Resources\Private\Templates\Page\