Search code examples
phptypo3typoscript

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. 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. 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.

When setting that value as special.value = 1, it works as expected.

Is it a problem with MenuProcessor's (i.e. HMENU) special.value and USER_INT? Are they incompatible somehow? Or am I missing something else here?

Thank you so much in advance!


Solution

  • 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.