Numbered headers based on layout

Submitting your vote...
Rating: 2.8 of 5. 6 vote(s).
Click the rating bar to rate this item.

This TypoScript Snippet changes the standard header layout, so headers will be prefixed with a number.

If first header is of type 1 (or default), then 1 digit number will be prefixed.

If the header following a header type 1, then 2 digit number will be prefixed and so on.

 

So a page with header types like this:

 

type1

type2

type2

type3

type2

type1

type1

 

would look like this:

 

1 header

1.1 header

1.2 header

1.2.1 header

1.3 header

2 header

3 header

 

Just paste the following code to the TYPO3 setup:

 

lib.stdheader.10.1 >
lib.stdheader.10.1 = COA
lib.stdheader.10.1 {
  10 = LOAD_REGISTER
  10.H1Counter.cObject = TEXT
  10.H1Counter.cObject.data = register:H1Counter
  10.H1Counter.cObject.wrap = |+1
  10.H1Counter.cObject.if.isTrue.current = 1
  10.H1Counter.prioriCalc = intval
  10.H2Counter = 0
  10.H3Counter = 0
  10.H4Counter = 0
  10.H5Counter = 0
   
  20 = TEXT
  20.current = 1
  20.insertData = 1
  20.fontTag = <h1{register:headerStyle}{register:headerClass}>{register:H1Counter}:&nbsp;|</h1>
}

lib.stdheader.10.2 >
lib.stdheader.10.2 < lib.stdheader.10.1
lib.stdheader.10.2 {
  10.H2Counter >
  10.H2Counter.cObject < .10.H1Counter.cObject
  10.H2Counter.cObject.data = register:H2Counter
  10.H2Counter.prioriCalc = intval
  10.H1Counter >
  20.fontTag = <h2{register:headerStyle}{register:headerClass}>{register:H1Counter}.{register:H2Counter}:&nbsp;|</h2>
}

lib.stdheader.10.3 >
lib.stdheader.10.3 < lib.stdheader.10.2
lib.stdheader.10.3 {
  10.H3Counter >
  10.H3Counter.cObject < .10.H2Counter.cObject
  10.H3Counter.cObject.data = register:H3Counter
  10.H3Counter.prioriCalc = intval
  10.H2Counter >
  20.fontTag = <h3{register:headerStyle}{register:headerClass}>{register:H1Counter}.{register:H2Counter}.{register:H3Counter}:&nbsp;|</h3>
}

lib.stdheader.10.4 >
lib.stdheader.10.4 < lib.stdheader.10.3
lib.stdheader.10.4 {
  10.H4Counter >
  10.H4Counter.cObject < .10.H3Counter.cObject
  10.H4Counter.cObject.data = register:H4Counter
  10.H4Counter.prioriCalc = intval
  10.H3Counter >
  20.fontTag = <h4{register:headerStyle}{register:headerClass}>{register:H1Counter}.{register:H2Counter}.{register:H3Counter}.{register:H4Counter}:&nbsp;|</h4>
}
lib.stdheader.10.5 >
lib.stdheader.10.5 < lib.stdheader.10.4
lib.stdheader.10.5 {
  10.H5Counter >
  10.H5Counter.cObject < .10.H4Counter.cObject
  10.H5Counter.cObject.data = register:H5Counter
  10.H5Counter.prioriCalc = intval
  10.H4Counter >
  20.fontTag = <h5{register:headerStyle}{register:headerClass}>{register:H1Counter}.{register:H2Counter}.{register:H3Counter}.{register:H4Counter}.{register:H5Counter}:&nbsp;|</h5>
}

 

 

This snippet was submitted by Peter Klein

 

This snippet is very similar to the following

Numbered SectionIndex based on header layout



Comments


Vincent, 03-12-08 08:42:
This is what I get on a page. It seems NOK. Using 4.2.2 and latest TemplaVoila.

1: Lorem ipsum dolor sit amet
.1: Lorem ipsum dolor sit amet 2
..1: Lorem ipsum dolor sit amet 3
1: Level 1
tobias, 05-12-08 14:04:
this snippet will not work with templavoila because the DS is out of scope
Bart, 22-11-11 14:32:
The solution to Vincents problem is described here: http://www.typo3.net/forum/beitraege/diverse_fragen/95963/

Empty lib.stdheader.98 and lib.stdheader.99, as the register gets restored there in newer TYPO3 versions. Obviously someone added this for a reason, but that reason is unclear.

Add comment

* - required field

*



*
*

Top 10 Updates

Useful Links geändert am  24-Apr-2013 06:31:20
Nice fonts using Google font API geändert am  20-May-2010 14:36:47
TS-based Searchbox for Indexed Search  geändert am  18-May-2010 16:27:15
TYPO3 SEO geändert am  30-Apr-2010 07:44:22
Search engine friendly graphical headers in TYPO3 geändert am  30-Apr-2010 07:33:44
Creating a simple Infocenter using TYPO3 geändert am  17-Nov-2009 11:12:52
Making the Section Menu work correctly with TemplaVoila geändert am  05-May-2009 10:27:17
Show pages with type "Not in Menu" in a sitemap geändert am  05-May-2009 10:11:17
Implementation of the DHTML menu from brainjar.com  geändert am  01-Feb-2009 13:02:48
Sample DHTML menu geändert am  01-Feb-2009 12:51:25

Latest comments

17-May-2013 10:09:34
Nicolas schrieb: If an extension or orther return a content empty, this solution not working. I not have the...
Wrap only if not empty
22-Apr-2013 12:08:26
morkel schrieb: hi i am new on typ03 and want to open a form on lightbox. when we click on image their a form will...
Using lightbox without extension
04-Mar-2013 13:33:47
Sebastian schrieb: Vergesse das immer wieder. Vielen Dank an dich und an Google :)
Wrap only if not empty
Deutsch
Search: