Search code examples
typesheadertypo3

Change Contents default header Type


I already created another question about tt_address. Now my question is about tt_content.

Since I've just upgraded from TYPO3 6 to TYPO3 9 I'm new to all things that were changed.

I have the problem that all my headings are displayed as H2. I could change it manually in all elements to H1 but that's not a thing for me. I want to set the standard Heading Type to H1. But all TypoScripts I found on the Internet do not work for me.

TypoScript that don't work for me:

content.defaultHeaderType = 1

styles.content.defaultHeaderType = 1

Solution

  • You can set the default via page-TSconfig in your root page:

    TCAdefaults.tt_content.header_layout = 1
    

    But '1' should already be default (if not changed manually) and this does only affect the pre-selected option (header layout dropdown) of new content elements. If you would like to change all existing headings, this would be possible f. e. via PhpMyAdmin

    UPDATE `tt_content` SET `header_layout` = '1' WHERE `header_layout` = '2'.
    

    If you would like to render headers with header_layout '2' as <h1>, you could edit the fluid-template /Partials/Header/Header.html (do not edit original, make a copy instead: https://docs.typo3.org/typo3cms/extensions/fluid_styled_content/Configuration/OverridingFluidTemplates/Index.html ).

    <f:case value="2">
        <h1 class="{positionClass}">
            <f:link.typolink parameter="{link}">{header}</f:link.typolink>
        </h1>
    </f:case>
    

    If you change the templates, you may consider renaming the available options. This is also possible via page-TSconfig

    TCEFORM{
        tt_content{
            header_layout{
                altLabels.1 = (h1) Headline
                altLabels.2 = ex (h2) Sub-Headline – NOW H1
                altLabels.3 = (h3) Sub-Sub-Headline
                removeItems = 0,4,5
            }
        }
    }