Background image on body tag with TypoScript

时间:2015-09-14 15:21:26

标签: typo3 typoscript typo3-6.2.x

I would like to assign every Page in TYPO3 Backend a Image. This image should be rendered as background image for my body tag, like.

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

I have the version 6.2LTS of TYPO3. In a previous TYPO3 Version (4.5) i realized a smilar solution with this typoscript part

page.bodyTagCObject = COA
page.bodyTagCObject {
    10 = TEXT
    10.value = <body style="background-image:url(
    20 = TEXT
    20 {
        data = levelmedia: -1 "slide"
        wrap = uploads/media/ |
        listNum = 0
    }
    30 = TEXT
    30.value = );">
}

The new TYPO3 Version works with file references, so i'm not sure how can i realize this issue.

Have someone a hint?

2 个答案:

答案 0 :(得分:4)

根据您的问题 - 是103它是文件参考的uid,请使用此代码段执行您想要的操作

page.bodyTagCObject = COA
page.bodyTagCObject {

  wrap = <body style="background-image:url('/|');">

  10 = FILES
  10 {
    references.data = levelmedia:-1,slide
    references.listNum = 0
    renderObj = TEXT
    renderObj.data = file:current:publicUrl
  }

}

答案 1 :(得分:1)

I use something similar on a Project, which runs TYPO3 v6.2.14.

You don't need the wrap since the filereference will give you the Path to the Image.

And slide doesnt need the quotation marks. Follwing Code should work:

 page.bodyTagCObject = COA
   page.bodyTagCObject {
        10 = TEXT
        10.value = <body style="background-image:url('
        20 = TEXT
        20 {
            data = levelmedia: -1, slide
        }
        30 = TEXT
        30.value = ');">
    }