TYPO3: Create a custom header layout

By default, TYPO3 has five default header layouts from which to choose. Each correspond to the H1 to H5 tags. With this TypoScript snippet you can adjust one of them and set it to your own needs. For example a header with a date attached to it. This way you can make a header like: Latest news of {date}. Or what about: Welcome back {username}?

A header with a date attached:

# Overwrite layout 5
# Create an array of objects
lib.stdheader.10.5 = COA
lib.stdheader.10.5 {
   # First object is a copy of the default header layout 1,
   # so the basic input is printed. (e.g. the field 'header')
   10 < lib.stdheader.10.1
   10.fontTag = <h2{register:headerStyle}{register:headerClass}>|

   # Second object: The date which we want to be appended.
   20 = TEXT
   20 {
      data = date:U
      strftime = %A %e %B
   }

   # Third object: Closing the H2 tag which we opened
   # in the first object.
   30 = TEXT
   30.value = </h2>
}

A header with the username

# Overwrite layout 5
# Create an array of objects
lib.stdheader.10.5 = COA
lib.stdheader.10.5 {
   # First object is a copy of the default header layout 1,
   # so the basic input is printed. (e.g. the field 'header')
   10 < lib.stdheader.10.1
   10.fontTag = <h2{register:headerStyle}{register:headerClass}>|

   # Second object: insert the username.
   20 = TEXT
   20.value = {TSFE:fe_user|user|name}
   20.insertData = 1

   # Third object: Closing the H2 tag which we opened
   # in the first object.
   30 = TEXT
   30.value = </h2>
}

Bookmark and Share

1 Comment »

 
 

Drop a comment