Typo3: Get typoscript values from custom condition

Hi friends,

I’m trying to write a custom condition for Typo3, which checks if a given TS value in another extension exists. Here’s what I have so far

class ValueExists extends \TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractCondition {

    /**
     * @param  array   $conditionParameters
     * @return boolean
     */
    public function matchCondition(array $conditionParameters) {
        
        foreach ($conditionParameters as $path) {
            $current = $GLOBALS['TSFE']->tmpl->setup;
            $keys = explode('.', $path);
            $last = count($keys) - 1;
            
            // Walk the setup path to look up the value
            foreach ($keys as $idx => $key) {
                $currentKey = $idx < $last
                    ? $key . '.'
                    : $key;

                if (!isset($current[$currentKey])) {
                    return false;
                } else {
                    $current = $current[$currentKey];
                }
            }
        }
        
        return true;
    }
}

Sample usage in typoscript would look like

[Myextension\ValueExists plugin.tx_anotherextesion.settings.somevalue]
    plugin.tx_thisextension.settings.somevalue = {$another_extension.settings.somevalue}
[global]

However, the weird thing is that the condition apparently gets colled multiple times, and the first time $GLOBALS['TSFE']->tmpl->setup consists only of ['siteTitle] so that it returns false. I have no idea what the reason could be… do you have any ideas?

Alternatively, do you have an idea how to achieve the same with the built in conditions, or maybe the typoscript if function? I’ve been trying quite a few possibilities, but ended up with the decision to write a custom condition… ^^

TIA
Sebastian

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.