Search code examples
typo3typoscriptpartialstypo3-9.x

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.


Solution

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