Typo3 Adding a class to the body tag on a specifc page

百般思念 提交于 2019-12-08 06:17:07

问题


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!


回答1:


Figured it out!

[globalVar = TSFE:id = 4]
page.bodyTag = <body class="page-speakers"> 
[end]



回答2:


We using 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 |>|   
    }
}



回答3:


Following will do

page.bodyTag >
page.bodyTagCObject = TEXT
page.bodyTagCObject.value= skin-blue 
page.bodyTagCObject.wrap = <body class="|">


来源:https://stackoverflow.com/questions/27236782/typo3-adding-a-class-to-the-body-tag-on-a-specifc-page

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!