flexform.xml 中的 TYPO3 (7.6.15) Extbase displayCond 在两个扩展之一中不工作
TYPO3 (7.6.15) Extbase displayCond in flexform.xml not working in one of two extensions
我一直在谷歌上搜索这个问题,但没有发现错误。
我使用 Extension Builder 编写了一个非常简单的扩展,它可以正常工作。但是仍然存在一个小错误。
该扩展用于课程和课程申请。这些课程有不同的类型。如果我想将插件元素添加到页面,我有两种不同类型的前端显示选项:一种用于主页,显示不同类型的课程,另一种用于列出相应的课程页面该类型的所有课程和注册表。这一切都很完美。因此,当我向页面添加插件元素时,我可以选择 "Home" 或 "Course page"。选择 Home 时,不应显示更多选项。选择 "course page" 时,应该会显示另一个包含不同课程类型的下拉元素。
直到最近我才意识到在我的 flexform 中我已经删除了 displayCond(不记得为什么),当然它显示了带有 "home" 和 "course page" 的课程类型的选项。但是如果我添加 displayCond 它不会显示任何一个选项。这是带有 displayCond 的 flexform 代码:
<?xml version="1.0" encoding="UTF-8"?>
<T3DataStructure>
<sheets>
<general>
<ROOT>
<TCEforms>
<sheetTitle>Kurse</sheetTitle>
</TCEforms>
<type>array</type>
<el>
<switchableControllerActions>
<TCEforms>
<label>Ansicht</label>
<onChange>reload</onChange>
<config>
<type>select</type>
<items type="array">
<numIndex index="0" type="array">
<numIndex index="0">Home</numIndex>
<numIndex index="1">Kurse->listHome</numIndex>
</numIndex>
<numIndex index="1" type="array">
<numIndex index="0">Kursseite</numIndex>
<numIndex index="1">Kurse->list;Kunde->sendMail</numIndex>
</numIndex>
</items>
</config>
</TCEforms>
</switchableControllerActions>
<settings.kursTypen>
<TCEforms>
<label>Kurstyp</label>
<config>
<type>select</type>
<foreign_table>tx_gicourses_domain_model_kurstyp</foreign_table>
<foreign_table_where>AND (sys_language_uid=CAST('###REC_FIELD_sys_language_uid###' AS UNSIGNED) OR sys_language_uid = '-1') AND tx_gicourses_domain_model_kurstyp.deleted = 0 AND tx_gicourses_domain_model_kurstyp.hidden = 0 order by name</foreign_table_where>
<size>1</size>
<minitems>1</minitems>
<maxitems>1</maxitems>
</config>
<displayCond>
<OR>
<numIndex index="1">FIELD:switchableControllerActions:=:Kurse->list</numIndex>
</OR>
</displayCond>
</TCEforms>
</settings.kursTypen>
</el>
</ROOT>
</general>
</sheets>
</T3DataStructure>
有趣的是,在另一个扩展中,我有一个相应的显示条件,它按预期工作:
<?xml version="1.0" encoding="UTF-8"?>
<T3DataStructure>
<sheets>
<general>
<ROOT>
<TCEforms>
<sheetTitle>Books</sheetTitle>
</TCEforms>
<type>array</type>
<el>
<switchableControllerActions>
<TCEforms>
<label>Ansicht</label>
<onChange>reload</onChange>
<config>
<type>select</type>
<items type="array">
<numIndex index="0" type="array">
<numIndex index="0">Alle</numIndex>
<numIndex index="1">Buch->list</numIndex>
</numIndex>
<numIndex index="1" type="array">
<numIndex index="0">Nach Kategorie</numIndex>
<numIndex index="1">Buch->listByCat</numIndex>
</numIndex>
</items>
</config>
</TCEforms>
</switchableControllerActions>
<settings.buchKategorie>
<TCEforms>
<label>Buchkategorie</label>
<config>
<type>select</type>
<foreign_table>tx_gibooks_domain_model_buchkategorie</foreign_table>
<foreign_table_where>AND (sys_language_uid=CAST('###REC_FIELD_sys_language_uid###' AS UNSIGNED) OR sys_language_uid = '-1') AND tx_gibooks_domain_model_buchkategorie.deleted = 0 AND tx_gibooks_domain_model_buchkategorie.hidden = 0 order by name</foreign_table_where>
<size>1</size>
<minitems>1</minitems>
<maxitems>1</maxitems>
</config>
<displayCond>
<OR>
<numIndex index="1">FIELD:switchableControllerActions:=:Buch->listByCat</numIndex>
</OR>
</displayCond>
</TCEforms>
</settings.buchKategorie>
</el>
</ROOT>
</general>
</sheets>
</T3DataStructure>
我想到的唯一区别是第一个扩展 (Kurse->list) 中的操作与第二个扩展 (Buch->listByCat) 中的操作相比是不可缓存的操作可缓存的动作。但是即使更改了这个,在选择插件元素时也没有任何改变。
这个问题可能来自哪里?我还需要检查其他东西吗?还有其他方法可以达到预期的效果吗?
我已经阅读了几个类似的问题,但是 none 中的问题表明我的代码存在问题(没有错字,条件正确..)尽管我已经阅读了几个错误与似乎已解决的 displayCond 有关。
由于我是 TYPO3 的新手,如果您能指出需要控制的文件,我将不胜感激 and/or 解释您的代码。谢谢
目前我可以让 "Home" 和 "course page" 都显示该选项,但对于不太喜欢使用计算机的人(编辑)来说,这可能会让人感到困惑。 ..
"Kurse->list" 在 Flexform XML 中的外观如何?它应该在那里读到 "Kurse->list" 否则你可能有一个标签不匹配
这是从臀部射出的半杆,但是你试过没有 <OR>
段吗?通常,当您只有一个条件要检查时,您不需要 <AND>
或 <OR>
- 我怀疑这会混淆条件,因此它会产生误报。尽管对此持保留态度 - 我什至不确定 displayCond
是否是检查一个字符串是否包含另一个字符串的正确方法。
就是说,FlexForm 值 resolving/checking 和 displayCond 都有修复 - 所以无论如何升级你的 TYPO3 版本当然是值得的(自你的版本以来已经有 7+ 个错误修复版本).
感谢 Claus Due,我发现了我的错误:
修正前我的显示条件:
FIELD:switchableControllerActions:=:Kurse->list
及之后:
FIELD:switchableControllerActions:=:Kurse->list;Kunde->sendMail
这就是当您复制一些应该有效但您甚至不了解它的作用时会发生的情况。感谢 Claus Due 的提示,我意识到这是一个字符串比较,比较的字符串与想要的字符串不匹配。
因此,如果有人想将其用于其他用途:您必须在 "FIELD:switchableControllerActions:=:"...
之后使用整个操作串
相当简单,不是吗...快乐编码
我有类似的东西。我的 displayCond
没有效果。我遵循了 TYPO3 Explained 教程中的说明。在给出的示例中,displayCond
放置在 config
标签内。
不工作:
<TCEforms>
<label>Label</label>
<config>
<displayCond>FIELD:switchableControllerActions:=:Extension->themes</displayCond>
<type>input</type>
</config>
</TCEforms>
工作:
<TCEforms>
<label>Label</label>
<displayCond>FIELD:switchableControllerActions:=:Extension->themes</displayCond>
<config>
<type>input</type>
</config>
</TCEforms>
我一直在谷歌上搜索这个问题,但没有发现错误。
我使用 Extension Builder 编写了一个非常简单的扩展,它可以正常工作。但是仍然存在一个小错误。
该扩展用于课程和课程申请。这些课程有不同的类型。如果我想将插件元素添加到页面,我有两种不同类型的前端显示选项:一种用于主页,显示不同类型的课程,另一种用于列出相应的课程页面该类型的所有课程和注册表。这一切都很完美。因此,当我向页面添加插件元素时,我可以选择 "Home" 或 "Course page"。选择 Home 时,不应显示更多选项。选择 "course page" 时,应该会显示另一个包含不同课程类型的下拉元素。
直到最近我才意识到在我的 flexform 中我已经删除了 displayCond(不记得为什么),当然它显示了带有 "home" 和 "course page" 的课程类型的选项。但是如果我添加 displayCond 它不会显示任何一个选项。这是带有 displayCond 的 flexform 代码:
<?xml version="1.0" encoding="UTF-8"?>
<T3DataStructure>
<sheets>
<general>
<ROOT>
<TCEforms>
<sheetTitle>Kurse</sheetTitle>
</TCEforms>
<type>array</type>
<el>
<switchableControllerActions>
<TCEforms>
<label>Ansicht</label>
<onChange>reload</onChange>
<config>
<type>select</type>
<items type="array">
<numIndex index="0" type="array">
<numIndex index="0">Home</numIndex>
<numIndex index="1">Kurse->listHome</numIndex>
</numIndex>
<numIndex index="1" type="array">
<numIndex index="0">Kursseite</numIndex>
<numIndex index="1">Kurse->list;Kunde->sendMail</numIndex>
</numIndex>
</items>
</config>
</TCEforms>
</switchableControllerActions>
<settings.kursTypen>
<TCEforms>
<label>Kurstyp</label>
<config>
<type>select</type>
<foreign_table>tx_gicourses_domain_model_kurstyp</foreign_table>
<foreign_table_where>AND (sys_language_uid=CAST('###REC_FIELD_sys_language_uid###' AS UNSIGNED) OR sys_language_uid = '-1') AND tx_gicourses_domain_model_kurstyp.deleted = 0 AND tx_gicourses_domain_model_kurstyp.hidden = 0 order by name</foreign_table_where>
<size>1</size>
<minitems>1</minitems>
<maxitems>1</maxitems>
</config>
<displayCond>
<OR>
<numIndex index="1">FIELD:switchableControllerActions:=:Kurse->list</numIndex>
</OR>
</displayCond>
</TCEforms>
</settings.kursTypen>
</el>
</ROOT>
</general>
</sheets>
</T3DataStructure>
有趣的是,在另一个扩展中,我有一个相应的显示条件,它按预期工作:
<?xml version="1.0" encoding="UTF-8"?>
<T3DataStructure>
<sheets>
<general>
<ROOT>
<TCEforms>
<sheetTitle>Books</sheetTitle>
</TCEforms>
<type>array</type>
<el>
<switchableControllerActions>
<TCEforms>
<label>Ansicht</label>
<onChange>reload</onChange>
<config>
<type>select</type>
<items type="array">
<numIndex index="0" type="array">
<numIndex index="0">Alle</numIndex>
<numIndex index="1">Buch->list</numIndex>
</numIndex>
<numIndex index="1" type="array">
<numIndex index="0">Nach Kategorie</numIndex>
<numIndex index="1">Buch->listByCat</numIndex>
</numIndex>
</items>
</config>
</TCEforms>
</switchableControllerActions>
<settings.buchKategorie>
<TCEforms>
<label>Buchkategorie</label>
<config>
<type>select</type>
<foreign_table>tx_gibooks_domain_model_buchkategorie</foreign_table>
<foreign_table_where>AND (sys_language_uid=CAST('###REC_FIELD_sys_language_uid###' AS UNSIGNED) OR sys_language_uid = '-1') AND tx_gibooks_domain_model_buchkategorie.deleted = 0 AND tx_gibooks_domain_model_buchkategorie.hidden = 0 order by name</foreign_table_where>
<size>1</size>
<minitems>1</minitems>
<maxitems>1</maxitems>
</config>
<displayCond>
<OR>
<numIndex index="1">FIELD:switchableControllerActions:=:Buch->listByCat</numIndex>
</OR>
</displayCond>
</TCEforms>
</settings.buchKategorie>
</el>
</ROOT>
</general>
</sheets>
</T3DataStructure>
我想到的唯一区别是第一个扩展 (Kurse->list) 中的操作与第二个扩展 (Buch->listByCat) 中的操作相比是不可缓存的操作可缓存的动作。但是即使更改了这个,在选择插件元素时也没有任何改变。
这个问题可能来自哪里?我还需要检查其他东西吗?还有其他方法可以达到预期的效果吗?
我已经阅读了几个类似的问题,但是 none 中的问题表明我的代码存在问题(没有错字,条件正确..)尽管我已经阅读了几个错误与似乎已解决的 displayCond 有关。
由于我是 TYPO3 的新手,如果您能指出需要控制的文件,我将不胜感激 and/or 解释您的代码。谢谢
目前我可以让 "Home" 和 "course page" 都显示该选项,但对于不太喜欢使用计算机的人(编辑)来说,这可能会让人感到困惑。 ..
"Kurse->list" 在 Flexform XML 中的外观如何?它应该在那里读到 "Kurse->list" 否则你可能有一个标签不匹配
这是从臀部射出的半杆,但是你试过没有 <OR>
段吗?通常,当您只有一个条件要检查时,您不需要 <AND>
或 <OR>
- 我怀疑这会混淆条件,因此它会产生误报。尽管对此持保留态度 - 我什至不确定 displayCond
是否是检查一个字符串是否包含另一个字符串的正确方法。
就是说,FlexForm 值 resolving/checking 和 displayCond 都有修复 - 所以无论如何升级你的 TYPO3 版本当然是值得的(自你的版本以来已经有 7+ 个错误修复版本).
感谢 Claus Due,我发现了我的错误:
修正前我的显示条件:
FIELD:switchableControllerActions:=:Kurse->list
及之后:
FIELD:switchableControllerActions:=:Kurse->list;Kunde->sendMail
这就是当您复制一些应该有效但您甚至不了解它的作用时会发生的情况。感谢 Claus Due 的提示,我意识到这是一个字符串比较,比较的字符串与想要的字符串不匹配。
因此,如果有人想将其用于其他用途:您必须在 "FIELD:switchableControllerActions:=:"...
之后使用整个操作串相当简单,不是吗...快乐编码
我有类似的东西。我的 displayCond
没有效果。我遵循了 TYPO3 Explained 教程中的说明。在给出的示例中,displayCond
放置在 config
标签内。
不工作:
<TCEforms>
<label>Label</label>
<config>
<displayCond>FIELD:switchableControllerActions:=:Extension->themes</displayCond>
<type>input</type>
</config>
</TCEforms>
工作:
<TCEforms>
<label>Label</label>
<displayCond>FIELD:switchableControllerActions:=:Extension->themes</displayCond>
<config>
<type>input</type>
</config>
</TCEforms>