[Typo3] (easy) way to distinguish the first content element in a column?

Ernesto Baschny [cron IT] ernst at cron-it.de
Tue Oct 4 14:16:03 CEST 2005


Martin Kindler schrieb am 04.10.2005 13:54:

> I am trying to give a special treatment to the very first (or last) content
> element in a column of my web site.
> How can I find out in TS whether the currently rendered cObject is the first
> (or last)?

To see if its the first one is easy:

  if.value=1
  if.equals.data = cObj:parentRecordNumber

cObj:parentRecordNumber is an counter for all records on the current
parent. So if its "1", its the first.

> To be more specific:
> I want to separate two content elements in a column by a separator element.
> This must not show at the beginning and
> end of the list.

Apply a CSS-style to the "header" of each element. There is already a
special class for the first header (in css_styled_content), which is
"csc-firstHeader", so you don't even need any special TS for this. Just
style:

  hX { border-top: 1px solid black; }
  hX.csc-firstHeader { border-top: none; }

where hX is your default header type.

If you need some more fancy "separator element" than what can already be
done with CSS, you can use the same trick (check for
cObj:parentRecordNumber) to "prepend" some cObject to every content
object BUT the first one. Something like:

  tt_content.stdWrap.preCObject = TEXT
  tt_content.stdWrap.preCObject {
    value = <hr />
    if.value = 1
    if.isGreaterThan.data = cObj:parentRecordNumber
  }

will add a <hr /> between each content element.

Cheers,
Ernesto



More information about the TYPO3-english mailing list