问题
Currently I am using the following conditional TypoScript to check which backend layout is set:
[globalVar = TSFE:page|backend_layout = 2]
// some typoscript
[global]
In addition I have a site tree structure like this:
- rootPage1
- page1
- page2
- page3
- rootPage2
- page1
- page2
Now I want to use a different backend layout for rootPage2 and all childs of this page. So I have configured this page as follows:
This works as expected and set a different backend layout for rootPage2 and all his childs, but the conditional statement is not working for his childs. Only if I set the backend layout for all this childs manually it is working :(.
Do I need a different conditional statement for this?
回答1:
Yes, you need to use different condition, specifically write your own userFunc condition
Put this code into your typo3conf/AdditionalConfiguration.php
(exactly in this place, create file if necessary):
function user_beLayout($layout) {
if (TYPO3_MODE!='FE') return false;
if($GLOBALS["TSFE"]->page["backend_layout"] > 0)
return $GLOBALS["TSFE"]->page["backend_layout"] == $layout;
foreach ($GLOBALS["TSFE"]->rootLine as $page)
if($page["backend_layout_next_level"] > 0)
return ($page["backend_layout_next_level"] == $layout);
return false;
}
So you can use it in your TS like:
[userFunc = user_beLayout(2)]
// some typoscript
[end]
And here's the link to gist with comments
来源:https://stackoverflow.com/questions/33301715/how-do-i-query-a-backend-layout-which-is-set-by-parent-page