Background image on body tag with TypoScript

2019-08-26 19:10发布

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条回答
该账号已被封号
2楼-- · 2019-08-26 20:12

According to your question - yes 103 it's uid of the file reference, use this snippet to do what you want

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
  }

}
查看更多
三岁会撩人
3楼-- · 2019-08-26 20:13

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 = ');">
    }
查看更多
登录 后发表回答