1

I need to get all of the visible nav menu items in a kentico 7 site. So far, I have the following:

Dim stuff As TreeNodeDataSet = TreeHelper.SelectNodes("/SiteSection/%")

which returns EVERYTHING (which I don't need). Limiting by class "CMS.MenuItem" narrows it down but not usably... it still returns a bunch of stuff that isn't visible.

Any suggestions?

2
  • when you say "isn't visible" is that content that is "unpublished"
    – nbushnell
    May 28, 2015 at 21:23
  • This is the navigation menu so when the page loads, I need only the top level navigation menu items and any subs that are under them when the mouse hovers over them and should not include any folder items, just nav items. May 28, 2015 at 21:24

1 Answer 1

1

You need to use the method overload that lets you pass in True for the SelectOnlyPublished value and for the nesting level pass in 1.

Dim stuff As TreeNodeDataSet = TreeHelper.SelectNodes("/SiteSection/%",True, "CMS.MenuItem","","nodeorder",1,True)

You can also add to the "where clause" something like "DocumentName not in('home','page1','page2')" if you want to exclude some specific documents.

3
  • Very close but it doesn't account for a dynamic level of submenus. If I increase the submenu level (nesting level), I get items that do not appear in the nav menu ever but are still set as published and sitemap May 28, 2015 at 21:35
  • you can add to the "where clause" something like "DocumentName not in('home','page1','page2')" if you want to exclude some specific documents. As for submenus you may have to do that in a sub query, nested repeater or hierarchical repeater.
    – nbushnell
    May 28, 2015 at 21:57
  • Ah, now that I know that, it looks like that will work. Thank you. May 29, 2015 at 13:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.