I'm trying to figure out how conditionally add a class to the body tag of a specific page. I'm trying to do it via typoscipt but haven't been able to figure it out. Maybe there's a better way to do it though. The site is using Typo3 version 4.4.6
I've tried this which didn't work
page.4.bodyTag >
page.4.bodyTagCObject = TEXT
page.4.bodyTagCObject {
field = uid
wrap = <body class="uid-|">
}
Any help or pointers would be greatly appreciated!
Figured it out!
[globalVar = TSFE:id = 4]
page.bodyTag = <body class="page-speakers">
[end]
We use the follwing snippet for TYPO3 4.5 and TYPO3 6.2. Outputs class and id like this on every page. Just style your css.
<body id="pid13" class="be- rpid13 level1 no-subs">
Snippet to place into root setup:
page {
bodyTagCObject >
bodyTagCObject = COA
bodyTagCObject {
### id of page in root level:
10 = TEXT
10.data = levelfield:1, uid
10.dataWrap = id="pid{TSFE:id}" class="be-{TSFE:beUserLogin} rpid|
### current level/depth of page
20 = TEXT
20.data = level:1
20.noTrimWrap = | level| |
### if page has subpages
30 = TEXT
30.value = has-subs
30.if.isTrue.numRows {
table = pages
where = pid=this
}
### if page has NO subpages
40 = TEXT
40.value = no-subs
40.if.negate = 1
40.if.isTrue.numRows {
table = pages
where = pid=this
}
50 = TEXT
50.value = "
stdWrap.noTrimWrap = |<body |>|
}
}
Since TYPO3 Version 9:
# Body Classes
[page["uid"] == 1]
page.bodyTag = <body class="home">
[END]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With