如何查询由父页面设置的后端布局? [英] How do I query a backend layout which is set by parent page?
问题描述
当前,我正在使用以下条件TypoScript来检查设置了哪种后端布局:
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
现在,我想对 rootPage2 和此页面的所有子项使用不同的后端布局.因此,我将该页面配置如下:
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:
这可以按预期工作,并为rootPage2及其所有子项设置了不同的后端布局,但条件语句不适用于其子项.只有当我手动为所有这些子项设置后端布局时,它才有效:(.
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?
推荐答案
Yes, you need to use different condition, specifically write your own userFunc condition
将此代码放入您的typo3conf/AdditionalConfiguration.php
中(正是在此位置,如有必要,请创建文件):
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;
}
因此您可以在TS中使用它,例如:
So you can use it in your TS like:
[userFunc = user_beLayout(2)]
// some typoscript
[end]
这篇关于如何查询由父页面设置的后端布局?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!