1

I want to load for every page the riht criticalCSS File.

So I saved them like this:

fileadmin/critical1.css for TSFE:id=1

fileadmin/critical2.css for TSFE:id=2

and so on. As there are a lot of pages I want the TS to be completely dynamic and NOT like this:

[globalVar = TSFE:id=1]
page {
  cssInline {
    10 = FILE
    10.file = fileadmin/critical1.css
  }
}
[global]

I want it like this:

page {
  cssInline {
    10 = FILE
    10.file= fileadmin/critical{page:uid}.css
  }
}

or this

page {
  cssInline {
    10 = FILE
    10.file= fileadmin/critical$GLOBALS['TSFE']->id.css
  }
}

But it is not working like this. Does anyone know how to do this?

4

1 回答 1

4

您只需要添加insertData = 1.

检查此代码:

page {
  cssInline {
    10 = FILE
    10.file= fileadmin/critical{page:uid}.css
    10.file.insertData = 1 
  }
}

参考: https ://docs.typo3.org/typo3cms/TyposcriptReference/Functions/Stdwrap.html?highlight=insertdata#insertdata


或者,您可以使用headerData.

检查此代码:

page {
  headerData {
    10 = TEXT
    10.value = {page:uid}
    10.insertData = 1 
    10.wrap = <link rel="stylesheet" type="text/css" href="fileadmin/critical|.css" media="all" />
  }
}

参考:https ://docs.typo3.org/typo3cms/TyposcriptReference/Setup/Page/Index.html#headerdata

希望这对你有帮助!

于 2018-02-19T04:26:33.947 回答