Burner
Burner

Reputation: 1071

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. 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

Upvotes: 1

Views: 934

Answers (1)

Dimitri Lavren&#252;k
Dimitri Lavren&#252;k

Reputation: 4889

It won't work because the .wrap part is always a string and not of type stdWrap itself, so it has no override propery. 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})">

Upvotes: 2

Related Questions