如何在 TYPO3 8 的常量编辑器中防止 "toggle-saving" 常量?
How to prevent "toggle-saving" constants in Constant-Editor of TYPO3 8?
我通过扩展生成器为 FE 用户注册创建了一个新扩展。
TYPO3 版本 8.7.7
我在设置下定义了两个常量(以在 extbase 和 fluid 中获取这些常量):
- 存储Pid
- 会员组
constants.ts有如下代码:
## Custom Sub-Categories
# customsubcategory=01_Storage=LLL:EXT:rmregistration/Resources/Private/Language/locallang_db.xlf:extension_configuration.customSubCategories.storage
# customsubcategory=02_Groups=LLL:EXT:rmregistration/Resources/Private/Language/locallang_db.xlf:extension_configuration.customSubCategories.groups
plugin.tx_rmregistration {
view {
# cat=plugin.tx_rmregistration/file; type=string; label=Path to template root (FE)
templateRootPath = EXT:rmregistration/Resources/Private/Templates/
# cat=plugin.tx_rmregistration/file; type=string; label=Path to template partials (FE)
partialRootPath = EXT:rmregistration/Resources/Private/Partials/
# cat=plugin.tx_rmregistration/file; type=string; label=Path to template layouts (FE)
layoutRootPath = EXT:rmregistration/Resources/Private/Layouts/
}
persistence {
# cat=plugin.tx_rmregistration//a; type=string; label=Default storage PID
storagePid =
}
settings {
# cat=plugin.tx_rmregistration/01_Storage/001; type=int[0-999]; label=LLL:EXT:rmregistration/Resources/Private/Language/locallang_db.xlf:extension_configuration.storagePid_and_description
storagePid =
# cat=plugin.tx_rmregistration/02_Groups/011; type=int[1-999]; label=LLL:EXT:rmregistration/Resources/Private/Language/locallang_db.xlf:extension_configuration.groupId_and_description
memberGroup =
}
}
setup.ts有如下代码:
plugin.tx_rmregistration {
view {
templateRootPaths.0 = EXT:rmregistration/Resources/Private/Templates/
templateRootPaths.1 = {$plugin.tx_rmregistration.view.templateRootPath}
partialRootPaths.0 = EXT:rmregistration/Resources/Private/Partials/
partialRootPaths.1 = {$plugin.tx_rmregistration.view.partialRootPath}
layoutRootPaths.0 = EXT:rmregistration/Resources/Private/Layouts/
layoutRootPaths.1 = {$plugin.tx_rmregistration.view.layoutRootPath}
}
persistence {
storagePid = {$plugin.tx_rmregistration.persistence.storagePid}
#recursive = 1
}
features {
#skipDefaultArguments = 1
# if set to 1, the enable fields are ignored in BE context
ignoreAllEnableFieldsInBe = 0
# Should be on by default, but can be disabled if all action in the plugin are uncached
requireCHashArgumentForActionArguments = 1
}
mvc {
#callDefaultActionIfActionCantBeResolved = 1
}
settings {
storagePid = {$plugin.tx_rmregistration.settings.storagePid}
memberGroup = {$plugin.tx_rmregistration.settings.memberGroup}
}
}
现在,如果我转到 Template-Module -> Constant-Editor -> PLUGIN.TX_RMREGISTRATION我找到了我的两个自定义常量,正如预期的那样。
但是如果我想更改值,我会遇到以下问题:
问题
初始情况:
- 我有一个活动字段,里面有一个值。
- 我有另一个没有值的字段(灰色)。
现在,如果我单击 edit-undo
按钮(在 memberGroups)并保存它,memberGroups 将被停用(灰色),但其他字段现在已激活。?!
我怎样才能防止这种“省电”???
我自己尝试修复的问题
- 清除整个缓存(fe-cache 和 system-cache)
- 通过安装工具清除整个缓存
- 清除浏览器缓存
我试图找出什么
- 请教高手google :D
- 搜索Whosebug系统
- 问我的程序员大师(他说这可能是一个错误粘贴的问题,但我不知道我会把错误的内容粘贴到哪里。
编辑
我更改了 sys_templates.php
和 tt_content.php
(如您在评论中所见),并且更改了 constants.txt(我删除了视图part和customsubcategories在下面的代码中(和上面一样)。
constants.ts
plugin.tx_rmregistration {
persistence {
# cat=plugin.tx_rmregistration/01_Storage/a; type=string; label=LLL:EXT:rmregistration/Resources/Private/Language/locallang_db.xlf:extension_configuration.storagePid_and_description
storagePid = 0
}
settings {
# cat=plugin.tx_rmregistration/01_Storage/a; type=int[1-999]; label=LLL:EXT:rmregistration/Resources/Private/Language/locallang_db.xlf:extension_configuration.storagePid_and_description
storagePid = 0
# cat=plugin.tx_rmregistration/02_Groups/a; type=int[2-999]; label=LLL:EXT:rmregistration/Resources/Private/Language/locallang_db.xlf:extension_configuration.groupId_and_description
memberGroup = 1
}
}
更改:默认值和可能输入的范围。
编辑:删除坏词设置(对问题不重要)
同样的问题
编辑 2
似乎是这样,失败效果(切换)只出现在 type=int[range]
常量中。
我做了一些测试。
首先我更改了常量:S & STR 常量为 type=string
和 M & T 常量为 type=int[range]
调试它的常量。
图例:
- [ ] 变灰
- 有价值的数字
测试 1:
- 之前:S [ ] M 2 T 3 STR [ ]
- 设置:S 1(更改字符串常量)
- 之后:S 1 M 2 T 3 STR [ ]
- 有效:是
测试 2:
- 之前:S 1 M 2 T 3 STR [ ]
- 设置:STR 3(更改字符串常量)
- 之后:S 1 M 2 T 3 STR 3
- 有效:是
测试 3:
- 之前:S 1 M 2 T 3 STR 3
- 设置:M [ ](更改一个 int[range] 常量)
- 之后:S 1 M [ ] T 3 STR 3
- 有效:第一个 int[range]-change yes
测试 4:
- 之前:S 1 M [ ] T 3 STR 3
- 设置:T [ ](尝试更改一个 int[range] 常量)
- 之后:S 1 M 2 T 3 STR 3
- 有效:这里又是切换错误(已标记)M 应该是 [ ]
经过多次测试和调试,我想我找到了解决方案。
我的 TypoScript 在以下几点是错误的:
如果我想使用带范围的整数,我必须将默认值包含到范围中,不是第一个可能的数字,在 default-value 之后。
不是这个
# cat=plugin.tx_rmregistration/02_Groups/a; type=int[2-999]; label=LLL:EXT:rmregistration/Resources/Private/Language/locallang_db.xlf:extension_configuration.groupId_and_description
memberGroup = 1
但是那个
# cat=plugin.tx_rmregistration/02_Groups/a; type=int[1-999]; label=LLL:EXT:rmregistration/Resources/Private/Language/locallang_db.xlf:extension_configuration.groupId_and_description
memberGroup = 1
此修复后的测试
String 或 Int[Range] 更改现在都在单值和 mutli-changing 值中起作用。
我通过扩展生成器为 FE 用户注册创建了一个新扩展。 TYPO3 版本 8.7.7
我在设置下定义了两个常量(以在 extbase 和 fluid 中获取这些常量):
- 存储Pid
- 会员组
constants.ts有如下代码:
## Custom Sub-Categories
# customsubcategory=01_Storage=LLL:EXT:rmregistration/Resources/Private/Language/locallang_db.xlf:extension_configuration.customSubCategories.storage
# customsubcategory=02_Groups=LLL:EXT:rmregistration/Resources/Private/Language/locallang_db.xlf:extension_configuration.customSubCategories.groups
plugin.tx_rmregistration {
view {
# cat=plugin.tx_rmregistration/file; type=string; label=Path to template root (FE)
templateRootPath = EXT:rmregistration/Resources/Private/Templates/
# cat=plugin.tx_rmregistration/file; type=string; label=Path to template partials (FE)
partialRootPath = EXT:rmregistration/Resources/Private/Partials/
# cat=plugin.tx_rmregistration/file; type=string; label=Path to template layouts (FE)
layoutRootPath = EXT:rmregistration/Resources/Private/Layouts/
}
persistence {
# cat=plugin.tx_rmregistration//a; type=string; label=Default storage PID
storagePid =
}
settings {
# cat=plugin.tx_rmregistration/01_Storage/001; type=int[0-999]; label=LLL:EXT:rmregistration/Resources/Private/Language/locallang_db.xlf:extension_configuration.storagePid_and_description
storagePid =
# cat=plugin.tx_rmregistration/02_Groups/011; type=int[1-999]; label=LLL:EXT:rmregistration/Resources/Private/Language/locallang_db.xlf:extension_configuration.groupId_and_description
memberGroup =
}
}
setup.ts有如下代码:
plugin.tx_rmregistration {
view {
templateRootPaths.0 = EXT:rmregistration/Resources/Private/Templates/
templateRootPaths.1 = {$plugin.tx_rmregistration.view.templateRootPath}
partialRootPaths.0 = EXT:rmregistration/Resources/Private/Partials/
partialRootPaths.1 = {$plugin.tx_rmregistration.view.partialRootPath}
layoutRootPaths.0 = EXT:rmregistration/Resources/Private/Layouts/
layoutRootPaths.1 = {$plugin.tx_rmregistration.view.layoutRootPath}
}
persistence {
storagePid = {$plugin.tx_rmregistration.persistence.storagePid}
#recursive = 1
}
features {
#skipDefaultArguments = 1
# if set to 1, the enable fields are ignored in BE context
ignoreAllEnableFieldsInBe = 0
# Should be on by default, but can be disabled if all action in the plugin are uncached
requireCHashArgumentForActionArguments = 1
}
mvc {
#callDefaultActionIfActionCantBeResolved = 1
}
settings {
storagePid = {$plugin.tx_rmregistration.settings.storagePid}
memberGroup = {$plugin.tx_rmregistration.settings.memberGroup}
}
}
现在,如果我转到 Template-Module -> Constant-Editor -> PLUGIN.TX_RMREGISTRATION我找到了我的两个自定义常量,正如预期的那样。
但是如果我想更改值,我会遇到以下问题:
问题
初始情况:
- 我有一个活动字段,里面有一个值。
- 我有另一个没有值的字段(灰色)。
现在,如果我单击 edit-undo
按钮(在 memberGroups)并保存它,memberGroups 将被停用(灰色),但其他字段现在已激活。?!
我怎样才能防止这种“省电”???
我自己尝试修复的问题
- 清除整个缓存(fe-cache 和 system-cache)
- 通过安装工具清除整个缓存
- 清除浏览器缓存
我试图找出什么
- 请教高手google :D
- 搜索Whosebug系统
- 问我的程序员大师(他说这可能是一个错误粘贴的问题,但我不知道我会把错误的内容粘贴到哪里。
编辑
我更改了 sys_templates.php
和 tt_content.php
(如您在评论中所见),并且更改了 constants.txt(我删除了视图part和customsubcategories在下面的代码中(和上面一样)。
constants.ts
plugin.tx_rmregistration {
persistence {
# cat=plugin.tx_rmregistration/01_Storage/a; type=string; label=LLL:EXT:rmregistration/Resources/Private/Language/locallang_db.xlf:extension_configuration.storagePid_and_description
storagePid = 0
}
settings {
# cat=plugin.tx_rmregistration/01_Storage/a; type=int[1-999]; label=LLL:EXT:rmregistration/Resources/Private/Language/locallang_db.xlf:extension_configuration.storagePid_and_description
storagePid = 0
# cat=plugin.tx_rmregistration/02_Groups/a; type=int[2-999]; label=LLL:EXT:rmregistration/Resources/Private/Language/locallang_db.xlf:extension_configuration.groupId_and_description
memberGroup = 1
}
}
更改:默认值和可能输入的范围。
编辑:删除坏词设置(对问题不重要)
同样的问题
编辑 2
似乎是这样,失败效果(切换)只出现在 type=int[range]
常量中。
我做了一些测试。
首先我更改了常量:S & STR 常量为 type=string
和 M & T 常量为 type=int[range]
调试它的常量。
图例:
- [ ] 变灰
- 有价值的数字
测试 1:
- 之前:S [ ] M 2 T 3 STR [ ]
- 设置:S 1(更改字符串常量)
- 之后:S 1 M 2 T 3 STR [ ]
- 有效:是
测试 2:
- 之前:S 1 M 2 T 3 STR [ ]
- 设置:STR 3(更改字符串常量)
- 之后:S 1 M 2 T 3 STR 3
- 有效:是
测试 3:
- 之前:S 1 M 2 T 3 STR 3
- 设置:M [ ](更改一个 int[range] 常量)
- 之后:S 1 M [ ] T 3 STR 3
- 有效:第一个 int[range]-change yes
测试 4:
- 之前:S 1 M [ ] T 3 STR 3
- 设置:T [ ](尝试更改一个 int[range] 常量)
- 之后:S 1 M 2 T 3 STR 3
- 有效:这里又是切换错误(已标记)M 应该是 [ ]
经过多次测试和调试,我想我找到了解决方案。
我的 TypoScript 在以下几点是错误的:
如果我想使用带范围的整数,我必须将默认值包含到范围中,不是第一个可能的数字,在 default-value 之后。
不是这个
# cat=plugin.tx_rmregistration/02_Groups/a; type=int[2-999]; label=LLL:EXT:rmregistration/Resources/Private/Language/locallang_db.xlf:extension_configuration.groupId_and_description
memberGroup = 1
但是那个
# cat=plugin.tx_rmregistration/02_Groups/a; type=int[1-999]; label=LLL:EXT:rmregistration/Resources/Private/Language/locallang_db.xlf:extension_configuration.groupId_and_description
memberGroup = 1
此修复后的测试
String 或 Int[Range] 更改现在都在单值和 mutli-changing 值中起作用。