-->

Background image on body tag with TypoScript

2019-08-26 20:00发布

问题:

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?

回答1:

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
  }

}


回答2:

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 = ');">
    }