[英]Typo3: Use USER_INT with HMENU's special.value
I'm just trying to compute, in my page.typoscript
file, a value programmatically, using PHP code.我只是想在我的page.typoscript
文件中使用 PHP 代码以编程方式计算一个值。 This is what I've done:这就是我所做的:
dataProcessing {
1010 = TYPO3\CMS\Frontend\DataProcessing\MenuProcessor
1010 {
levels = 2
special = directory
special.value = USER_INT
special.value {
userFunc = Vendor\Extension\Utils\NavigationBarUtils->getPlatformRootPid
}
as = menuMain
}
...
}
And the method called is this one:调用的方法是这个:
public function getPlatformRootPid(): int
{
return 1;
}
When I load whatever page menuMain
is null.当我加载任何页面时, menuMain
为空。 The namespace is correct.命名空间是正确的。 Also, I've used methods like this to compute some other values in that same page.typoscript
file, and they work.此外,我已经使用这样的方法来计算同一个page.typoscript
文件中的一些其他值,并且它们可以工作。
When setting that value as special.value = 1
, it works as expected.将该值设置为special.value = 1
,它会按预期工作。
Is it a problem with MenuProcessor's (ie HMENU) special.value
and USER_INT?它是用MenuProcessor的(即HMENU)问题special.value
和USER_INT? Are they incompatible somehow?他们不知何故不兼容? Or am I missing something else here?还是我在这里错过了其他东西?
Thank you so much in advance!非常感谢您!
I think you missed types.我想你错过了类型。
special.value
expects a value, which might get modified by .stdWrap
functions. special.value
需要一个值,该值可能会被.stdWrap
函数修改。
you try to modify an attribute to be an object, which can't work.您尝试将属性修改为对象,这是行不通的。
you assigned the value (string) USER_INT
and the stdWrap function userFunc
, which does not exist.您分配了值(字符串) USER_INT
和不存在的 stdWrap 函数userFunc
。
if you want to use an object for a value you need to use .cObject
.如果你想使用一个对象作为一个值,你需要使用.cObject
。 So your solution probably is:所以你的解决方案可能是:
1010 {
levels = 2
special = directory
special.value.cObject = USER_INT
special.value.cObject {
userFunc = Vendor\Extension\Utils\NavigationBarUtils->getPlatformRootPid
}
as = menuMain
}
In the end, I've figured out a way to do it:最后,我想出了一种方法来做到这一点:
1010 {
levels = 2
special = directory
special.value.postUserFunc = Vendor\Extension\Utils\NavigationBarUtils->getPlatformRootPid
as = menuMain
}
In effect it does what I wanted, set that value programmatically by calling a PHP method.实际上,它完成了我想要的操作,通过调用 PHP 方法以编程方式设置该值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.