[TYPO3-templavoila] how to map to a body attribute?

Christopher Torgalson bedlamhotelnospam at gnospammail.com
Thu Jan 18 18:21:03 CET 2007


Dmitry Dulepov wrote:
> Hi!
> 
> Christian Welzel wrote:
>> That would be a solution if i can set this property using the TO of tv.
>> is that possible?
> 
> No, tv has no access to TLOs... If you plan to do it through page 
> template, you can easily extend page record by making an extension and 
> add one more field to page record, which will be a class name or link to 
> additional css file (which is more generic).

You can also use page.bodyTagCObject (as Dmitry mentioned) and set the 
value based on the contents of the field tx_templavoila_to or 
tx_templavoila_next_to in the pages table.

I can't take time to test it out at the moment, but I would start with a 
nested CASE cObject something like what's shown below. Since 
tx_templavoila_to is not set for every page, you will have to use 
'slide' to find the nearest value of tx_templavoila_next_to. It will be 
tricky, but should be do-able.

You may also have to add tx_templavoila_to and tx_templavoila_next_to to 
the rootline ([FE][addRootLineFields] in install tool).


# Set up the body tags:

lib.bodyTag.1 = HTML
lib.bodyTag.1.value = <body class="class_1">

lib.bodyTag.2 = HTML
lib.bodyTag.2.value = <body class="class_2">


# Totally untested code:

bodyTagCObject = CASE
bodyTagCObject {
	key.field = tx_templavoila_to

	# if key field is not set:
	default = CASE
	default {
		key.data = levelfield : -1 , tx_templavoila_next_to, slide
		1 < lib.bodyTag.1
		2 < lib.bodyTag.2
	}

	# if key field is 1:
	1  < lib.bodyTag.1

	# if key field is 2:
	2  < lib.bodyTag.2
}



-CT


More information about the TYPO3-project-templavoila mailing list