AFX Loop item.node property

Hi guys,

I need your help once again (Sorry, but I’m not a fan of the documentation).

I want to render a submenu, but only if the node-property (declared in yaml-file) hasSubMenu is true.

<Neos.Fusion:Loop items={props.menuItems}>
    <li class={(item.state + " li__level--one" + (item.subItems && item.property.hasSubMenu? " hasSub" : ""))}>
        <Neos.Neos:NodeLink node={item.node} @if.hasSubMenu={!item.property.hasSubMenu} attributes.class="navLink">
             {item.label}
        </Neos.Neos:NodeLink>
        <span class="navLink openSub" @if.hasSubMenu={item.property.hasSubMenu}>{item.label}</span>
        <div class="nav__level--two__container" @if.hasSubMenu={item.property.hasSubMenu}>
            <ul class="nav__level---two">
            </ul>
        </div>
    </li>
<Neos.Fusion:Loop

Is there any possibilty to get the node-property hasSubMenu from the items?

This would also be great to display the meta-description (or any other custom properties) in the submenu.

Thanks in advance :slight_smile:

Best guess (disclaimer: I don’t do much Neos CMS work)

item.node.properties.hasSubMenu would give you the value of the property"hasSubMenu".

Similar, you have access to all other properties such as meta data properties etc for you to use as you like

1 Like

Use q(item.node).property('hasSubMenu')

The item.node thing is actually in the docs on https://docs.neos.io/cms/tutorials/rendering-a-menu-in-fluid :wink:

1 Like

Thanks, both solutions work perfectly.

  • q(item.node).property('hasSubMenu')
  • item.node.properties.hasSubMenu

The .property method is faster as it only loads value, where properties loads all and then selects one

4 Likes