typo3 - Missing child nodes in view helper -


i created view helper used work on typo3 7.6 stopped working on typo3 8.7. renders else part though return value of evaluatecondition correct while debugging.

while debugging see abstractconditionviewhelper in abstractconditionviewhelper gets called , there renderthenchild or renderelsechild called. there child nodes missing.

my view helper:

<?php  namespace vendor\extkey\viewhelpers;  class ifregexpviewhelper extends \typo3\cms\fluid\core\viewhelper\abstractconditionviewhelper {      /**      * initialize arguments      * @throws \typo3\cms\fluid\core\viewhelper\exception      */     public function initializearguments() {         $this->registerargument('then', 'mixed', 'value returned if condition if met.', false);         $this->registerargument('else', 'mixed', 'value returned if condition if not met.', false);         $this->registerargument('value', 'string', 'the value', true);         $this->registerargument('pattern', 'string', 'the regex pattern check', true);     }      /**      * check if pattern matches      *      * @param array $arguments viewhelper arguments evaluate condition viewhelper, allows flexiblity in overriding method.      * @return string rendered string      * @api      */     protected static function evaluatecondition($arguments = null)     {         if (preg_match($arguments['pattern'], $arguments['value']) === 1) {             return true;         } else {             return false;         }     } } 

usage in template:

<f:if condition="{eddaylight:ifregexp(value: overview, pattern: '/[a-za-z0-9]+/')}">     <f:then>         {overview}     </f:then>     <f:else>         else     </f:else> </f:if> 

is there need child nodes parsed?

<f:if condition="{eddaylight:ifregexp(value: overview, pattern: '/[a-    za-z0-9]+/')}">     <f:then>         {overview}     </f:then>     <f:else>         else     </f:else> </f:if> 

is wrong - viewhelper have written condition viewhelper itself, returns either value of then or else node/closure/argument , if none specified, nothing returned. you've written above same as:

<f:if condition=""> 

which false.

the way use viewhelper is:

<eddaylight:ifregexp value="{overview}" pattern="/[a-za-z0-9]+/">     <f:then>         {overview}     </f:then>     <f:else>         else     </f:else> </eddaylight:ifregexp> 

same applies every other subclass of abstractconditionviewhelper.

note childnodes:

  • in current use case there rightfully no child nodes since write viewhelper in inline notation without passing child value.
  • if expand correct syntax see child nodes, but until template gets compiled, @ time child nodes no longer set.

Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -