Fluid inline condition & item.subItems


(Thomas Grabietz) #1

Hallo All,

the inline conditions does not work anymore with {item.subItems} after upgrading a website from NEOS 2 to 3.3.9 in the Menu - Context

{namespace neos=Neos\Neos\ViewHelpers}
<f:for each="{items}" as="item">
  <li class="{f:if(condition: '{item.subItems}',then: 'has-sub')}">
    <neos:link.node node="{item.node}">{item.label}
    </neos:link.node>
  </li>
</f:for>

Warning: htmlspecialchars() expects parameter 1 to be string, array given in ...


(Soren Malling) #2

Can you try and set

<f:debug>{items}</f:debug>

To see what you actually get to work with


(Thomas Grabietz) #3

debug kills the browser, I think the output has circular dependencies.

But I know, that item.subItems is an array. If the array is empty, this line is executed and the menu items are rendered. In case that the item has subitems I see this warning and nothing is rendered.
This code fails also with a fresh installed vanilla neos website…

BTW: this notation works:
<f:if condition="{item.subItems}"> …

works


(Bastian Waidelich) #4

You could try

<li class="{f:if(condition: item.subItems, then: 'has-sub')}">