Kentico 7: MVC, VB, trying to get only the list of visible nav menu items

Doug Hicks asked on May 28, 2015 23:01

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?

Correct Answer

Brenden Kehren answered on May 28, 2015 23:09

Include DocumentMenuItemHideInNavigation = 0 in your where clause which will only get the pages that don't have the checkbox checked in the UI under Page>Properties>Navigation>Show in navigation.

0 votesVote for this answer Unmark Correct answer

Recent Answers


Doug Hicks answered on May 28, 2015 23:20 (last edited on May 28, 2015 23:28)

Thanks, that is almost what I need. It narrows it down by leaps and bounds. What I really need is to get only the items for the nav menu that show on page load and any sub menu items that show on mouse hover and not anything that is in subfolders for those items.

I've tried a few variations on the where like

DocumentMenuItemShowInNavigation DocumentMenuItemHideInSiteMap DocumentMenuItemShowInSiteMap

but those all give me errors.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on May 28, 2015 23:39

I think this is the syntax, been a while since I used it but you can limit the number of levels you go down. If you want to only go 2 levels deep then use this in your where clause MaxRelativeLevel = 2

0 votesVote for this answer Mark as a Correct answer

Doug Hicks answered on May 29, 2015 15:08

Thanks. I think that makes sense.

0 votesVote for this answer Mark as a Correct answer

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