get children of CMS.Menu

web dev asked on January 21, 2019 18:21

hello kentico dev i try to apply transformation to get children of page but i want get only item of cms.menuitem i try this but didnt work any idea thanks

`{%foreach (x in Documents[NodeAliasPath].Children.Where(x => x.ClassName == "cms.menuitem")){ %}

  • <a class="banking-sub-menu-item" href="{%GetDocumentUrl%}/{%x.DisplayName.Replace(" ","-")#%}" aria-haspopup="true" aria-expa

          nded="false"
          data-for="subinfo-{%x.DisplayName.Replace(" ","-").ToLower()#%}">{%x.DisplayName#%}</a>
        </li>
        {%}#%}
      </ul>
    
      <div class="banking-sub-menu-content">
        {%foreach (x in Documents[NodeAliasPath].Children.Where(x => x.ClassName == "cms.menuitem")){ %}
        <div class="banking-sub-menu-content-block" data-info="subinfo-{%x.DisplayName.Replace(" ","-").ToLower()#%}">
           {%Documents.WithAllData[x.NodeAliasPath].GetValue("MenuItemDescription") %} 
        </div> 
        {%}#%}
      </div>`
    
  • Correct Answer

    Peter Mogilnitski answered on January 21, 2019 18:26

    try this: Documents[NodeAliasPath].Children.Where("ClassName = 'cms.menuitem'")

    0 votesVote for this answer Unmark Correct answer

       Please, sign in to be able to submit a new answer.