SelectNodes filtered by menu group

Eoin Maguire asked on April 3, 2014 09:01

Is there a way to filter the results of a TreeHelper.SelectNodes query so that I can do something like "Where menu item group = 'whatever'"?

Correct Answer

Brenden Kehren answered on April 3, 2014 10:06

Check out the API Examples for v7.

Here is a snippet that should work for you. The key is providing the WHERE clause. `

CMS.DocumentEngine.TreeProvider tree = new CMS.DocumentEngine.TreeProvider(CMS.CMSHelper.CMSContext.CurrentUser);

DataSet documents = tree.SelectNodes(CMS.CMSHelper.CMSContext.CurrentSiteName, "/API-Example/%", "en-us", false, "CMS.MenuItem", "MenuItemGroup = 'MyGroup'");`
1 votesVote for this answer Unmark Correct answer

Recent Answers


Eoin Maguire answered on April 3, 2014 10:25

Thank you for replying, I'm running into problems with this for days with no progress. Anyway, the snippet doesn't give me any errors but isn't working either so far. It's returning null at the moment, I believe due to the where clause not working.

DataSet ds = tree.SelectNodes(CMSContext.CurrentSiteName, "/%", "en-us", false, "CMS.MenuItem", "MenuItemGroup = 'Upper Top'");

0 votesVote for this answer Mark as a Correct answer

Eoin Maguire answered on April 3, 2014 10:29

Bit more detail (BTW, it very annoying how you can't edit your questions here), apparently the DB removes spaces from menuitemgroup names so my query just needed the spaces removed. It works. THanks, you've saved me from epic frustration.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on April 3, 2014 14:28

The dropdown value is set in the cms.menuitem document type. You can see the values and names there if you're looking for additional values.

0 votesVote for this answer Mark as a Correct answer

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