Setting FCE Header from it’s Content Element Header

This article explains about how to set an FCE header from it’s content element header.

Whenever we create content element from Typo3, we have noticed that each content element can have a header, and we can set various styles for this header, such as from layout 1 to layout 6, and it can even be hidden from front-end. When we set this header for an FCE, we notice that the header will not be present within the FCE content, but it will be outside it!!! We can even create a header within FCE and map it, but an editor may have to either enter the header twice, or he may be confused which one to use.

This code below helps you overcome this and we can make use of the header specified for FCE content element, as the header within our FCE.

Now let us call our FCE field as field_header, and let us define this as a Typoscript Object.

<field_header>
    <tx_templavoila type="array">
        <title>FCE Header</title>
        <sample_data type="array">
            <numIndex index="0">[ FCE Header / Title ]</numIndex>
        </sample_data>
        <eType>TypoScriptObject</eType>
        <TypoScriptObjPath>lib.mypaneltitle</TypoScriptObjPath>                   
        <description>Map to FCE Header container</description>
    </tx_templavoila>               
</field_header>

The above field must be mapped like we do in any FCE Template Object. Now Enter the Typoscript part of this as follows:

lib.mypaneltitle= TEXT
lib.mypaneltitle{
     data = register:tx_templavoila_pi1.parentRec.header
}

bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

7 thoughts on “Setting FCE Header from it’s Content Element Header”

  1. Hi,

    there is an even easier way to do this:

    Header

    [ Logo ]

    TypoScriptObject
    <![CDATA[

    10
    10.setCurrent.data = register:tx_templavoila_pi1.parentRec.header
    10.key.field >
    10.key.data = register:tx_templavoila_pi1.parentRec.header_layout
    ]]>
    Map to header container (class=cw_box_title)

    CU,
    Seb

  2. Hi,spabhat

    ihave fce which contains title and content and title is taking h1 as default heading,I just want to change it to h3 but I still not getting it ,if you provide me whole process how to change this,it will be very helpful for me.

    As I change it from layout type from each page than the changes occurs but I need to do it it whole template.
    So that I have to make one change and it will reflect in whole.
    Thanks

  3. Hi Harshit,

    I have given complete code which covers h1 to h6!.
    I could not get what else you are looking for!

  4. This is very tricky. We need to get this information from lib.stdheader.
    I am using a method as shown below which would work almost similar.

    <field_header type=”array”>
    <tx_templavoila type=”array”>
    <title>Header</title>
    <sample_data type=”array”>
    <numIndex index=”0″>[ Logo ]</numIndex>
    </sample_data>
    <eType>TypoScriptObject</eType>
    <TypoScript><![CDATA[

    10 = CASE
    10 {
    default = TEXT
    default {
    data = register:tx_templavoila_pi1.parentRec.header
    typolink.parameter.data = register:tx_templavoila_pi1.parentRec.header_link
    wrap = <h1>|</h1>
    }
    1 < .default
    1.wrap = <h2>|</h2>
    2 < .default
    2.wrap = <h3>|</h3>
    3 < .default
    3.wrap = <h4>|</h4>
    4 < .default
    4.wrap = <h5>|</h5>
    5 < .default
    5.wrap = <h6>|</h6>
    7 < .default
    7.wrap = |

    100 < .default
    100.wrap = <span style=”display:none”>|</span>

    key.data = register:tx_templavoila_pi1.parentRec.header_layout

    }

    ]]></TypoScript>
    <description>Map to header container (class=cw_box_title)</description>
    </tx_templavoila>
    </field_header>

  5. Instead of TypoScriptObjPath we can use typoscript directly as shown:
    <field_header type=”array”>
    <tx_templavoila type=”array”>
    <title>Header</title>
    <sample_data type=”array”>
    <numIndex index=”0″>[ Logo ]</numIndex>
    </sample_data>
    <eType>TypoScriptObject</eType>
    <TypoScript><![CDATA[

    10 = TEXT
    10.data = register:tx_templavoila_pi1.parentRec.header
    10.typolink.parameter.field = field_linkurl
    ]]></TypoScript>
    <description>Map to header container (class=cw_box_title)</description>
    </tx_templavoila>
    </field_header>

Comments are closed.