简体   繁体   English

当常量不为空时,如何更改Typo3 BodyTag

[英]How can I change Typo3 BodyTag, when a constant is not empty

I want to set a class and a style attribute in the Body-Tag. 我想在Body-Tag中设置一个类和一个style属性。 But only if a Constant is set. 但仅当设置了常量时。

Constant: 不变:

page.theme.bodybackgroundpicture = fileadmin/pageBackground.png

Setup: 设定:

temp.body = COA
temp.body {
  10 = TEXT
  10.value = {$page.theme.bodybackgroundpicture}
  10.stdWrap.wrap = <body class="background" style="background-image: url(|)">
  10.stdWrap.wrap.override = <body>
  10.stdWrap.wrap.override.ifEmpty = {$page.theme.bodybackgroundpicture}
}

page.bodyTagCObject < temp.body

It should be 它应该是

<body class="background" style="background-image: url(fileadmin/pageBackground.png)">

or if constant is empty 或如果常量为空

<body>

But this don't work, where is my Error? 但这不起作用,我的错误在哪里? Can anybody help me? 有谁能够帮助我? Thank you 谢谢

It won't work because the .wrap part is always a string and not of type stdWrap itself, so it has no override propery. 它不会起作用,因为.wrap部分始终是一个字符串,而不是stdWrap本身,因此它没有覆盖属性。 You could create two objects with different if conditions like that 您可以创建两个具有不同条件的对象

temp.body = COA
temp.body {
  10 = TEXT
  10.value = {$page.theme.bodybackgroundpicture}
  10.stdWrap.wrap = <body class="background" style="background-image: url(|)">
  10.if.isTrue = {$page.theme.bodybackgroundpicture}
  20 = TEXT
  20.value = <body>
  20.if.isFalse = {$page.theme.bodybackgroundpicture}
}

This should also work: 这也应该起作用:

10.value =  <body class="background" style="background-image: url({$page.theme.bodybackgroundpicture})">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM