typo3bootstrap-5typo3-extensions

TYPO3: How to overwrite bootstrap_package template?


How to override bootstrap_package templates with sitepackage's template in TYPO3? I tried this code in the my sitepackage setup.typoscript.

plugin.tx_bootstrap_package {
    view {
        templateRootPaths {
            0 = EXT:bootstrap_package/Resources/Private/Templates/
            1 = EXT:fileadmin/templates/ext/bootstrap_package/Templates/
        }
        partialRootPaths {
            0 = EXT:bootstrap_package/Resources/Private/Partials/
            1 = fileadmin/templates/ext/bootstrap_package/Partials/
        }
        layoutRootPaths {
            0 = EXT:bootstrap_package/Resources/Private/Layouts/
            1 = fileadmin/templates/ext/bootstrap_package/Layouts/
        }
    }
}

Solution

  • This kind of problem could be identified by looking at the current TypoScript of a page.
    Use the Templatemodule in the backend, select a page and then use the TSOB (TypoScript-Object-Browser) (selection in the drop down at the top of the working area)

    Here you can select some configurations:
    Constants/Setup: setup is the working configuration, but constants may prepare some data for the setup.

    My preferences:

    [x] Display comments  
    [x] Sort alphabetically  
    Display Constants [Substituted constants in green  V]
    

    You also may need to switch conditions for individual pages.

    then you can see the active TypoScript. where you can find that there is no structure which you have set.

    in the Constants you have the values:

    plugin.bootstrap_package {
        view {
            templateRootPath = EXT:bootstrap_package/Resources/Private/Templates/
            partialRootPath = EXT:bootstrap_package/Resources/Private/Partials/
            layoutRootPaths = EXT:bootstrap_package/Resources/Private/Layouts/
        }
    }
    

    these constants are used only in:

    plugin.tx_seo {
        view {
            templateRootPaths {
                20 = EXT:bootstrap_package/Resources/Private/Templates/Seo/
                21 = {$plugin.bootstrap_package.view.templateRootPath}Seo/
            }
            partialRootPaths {
                20 = EXT:bootstrap_package/Resources/Private/Partials/Seo/
                21 = {$plugin.bootstrap_package.view.partialRootPath}Seo/
            }
            layoutRootPaths {
                20 = EXT:bootstrap_package/Resources/Private/Layouts/Seo/
                21 = {$plugin.bootstrap_package.view.layoutRootPath}Seo/
            }
        }
    }
    

    in the Setup these constants are used:

    page {
      10 {
        templateRootPaths {
            0 = EXT:bootstrap_package/Resources/Private/Templates/Page/
            1 = {$page.fluidtemplate.templateRootPath}
        }
        partialRootPaths {
            0 = EXT:bootstrap_package/Resources/Private/Partials/Page/
            1 = {$page.fluidtemplate.partialRootPath}
        }
        layoutRootPaths {
            0 = EXT:bootstrap_package/Resources/Private/Layouts/Page/
            1 = {$page.fluidtemplate.layoutRootPath}
        }
      }
    }
    

    (as Julian already wrote.)
    if you substitute these constants it may look like:

    page {
      10 {
        templateRootPaths {
            0 = EXT:bootstrap_package/Resources/Private/Templates/Page/
            1 = EXT:site_extension/Resources/Private/Templates/Page/
        }
        partialRootPaths {
            0 = EXT:bootstrap_package/Resources/Private/Partials/Page/
            1 = EXT:site_extension/Resources/Private/Partials/Page/
        }
        layoutRootPaths {
            0 = EXT:bootstrap_package/Resources/Private/Layouts/Page/
            1 = EXT:site_extension/Resources/Private/Layouts/Page/
        }
      }
    }
    

    If you have more paths you can insert additional values which are inspected in top down order for a matching FLUID template.


    there are additional template paths in the bootstrap package, but those are relevant for CEs (content elements) and use other constants:

    lib.contentElement {
        templateRootPaths {
            0 = EXT:bootstrap_package/Resources/Private/Templates/ContentElements/
            10 = {$plugin.bootstrap_package_contentelements.view.templateRootPath}
        }
        partialRootPaths {
            0 = EXT:bootstrap_package/Resources/Private/Partials/ContentElements/
            10 = {$plugin.bootstrap_package_contentelements.view.partialRootPath}
        }
        layoutRootPaths {
            0 = EXT:bootstrap_package/Resources/Private/Layouts/ContentElements/
            10 = {$plugin.bootstrap_package_contentelements.view.layoutRootPath}
        }
    }