January 17, 2007

Changing the Default Header for Content Elements

Cat: TYP03, TypoScript

Setting the constants that controls the header level for the default layout.

Early in my TYPO3 work I continually found myself having to change the header of content elements to something other than the default of H1. Normally, I would leave alone the first headline on a page (which usually echoed the page title) but other headlines I would usually set to something else (often an H3). I did this not only because multiple H1's would overpower the page visually but also I wanted a more sensible semantic layout.

Bottom line, I found myself continually changing the header type. I also began to be concerned with the ramifications when I turned over the day to day editing of the site to someone less in tune with the proper use of header levels. I imagined an epidemic of H1 headers.

However, after a little research I found the TYPO3 constant that controls what type of header is used by default for content elements.

In the constants field (not setup) of your typoscript template add:

content.defaultHeaderType = 3

From that point in the page tree each header assigned a layout of "default" will be an H3. Change the "3" to another number and you will have the corresponding header level (i.e. change it to a "2" and you will have a default of H2).

 

Comments

Nice! I have not run into this issue yet, simply because the sites I've worked on have been so simple, I've just styled the h1 to be smaller and not used it anyplace else...

There are a lot of features like this in typo3, and I sometimes find them overwhelming and maybe even hard to find. When you say 'a little research', where did you find this?

cheers
Andrew Davis, 01/18/07
 
Funny you should ask. I tried to figure out where I had originally found it. But after searching tsRef, Typoscript by Example, etc. I could not find it. I think I may have just asked someone once after searching for it and they put me on the right path.
Ron Hall, 01/19/07
 

Post a Comment

Please note that it can take a minute or two to save your comment. Wait for the page to refresh to see your comment.