Document tree

Mateusz Żebrowski asked on July 22, 2014 09:52

I have this piece of code:

CMS.DocumentEngine.TreeNodeDataSet Nodes = TreeHelper.SelectNodes("/%");

It selects all documents marked as "Show in navigation" (in CMSdesk select document Properties/Navigation/Basic properties). I wish to select all documents whether it is mark or not. How can I make it?

Recent Answers


Brenden Kehren answered on July 22, 2014 13:35

CMS.DocumentEngine.TreeNodeDataSet Nodes = TreeHelper.SelectNodes("/%").Where("(DocumentMenuItemHideInNavigation = 0 OR DocumentMenuItemHideInNavigation = 1)");
0 votesVote for this answer Mark as a Correct answer

Mateusz Żebrowski answered on July 22, 2014 15:08

Sorry but this code is incorrect. I've copy and paste it and try to modified it but it still not working.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on July 22, 2014 16:22

I copied your code and added the Where() statement, what's incorrect about it? What's not working?

0 votesVote for this answer Mark as a Correct answer

Ashish Narnoli answered on July 23, 2014 08:12

Hi Mateusz,

Are you using v7?

Try TreeHelper.SelectNodes(aliasPath, combineWithDefaultCulture, classNames, where) version of SelectNodes Method.

Hopefully it will work :)

Best Regards! Ashish Narnoli

0 votesVote for this answer Mark as a Correct answer

Mateusz Żebrowski answered on July 23, 2014 08:53

It's better (it's correct) but it still change nothing. It still displays nodes marked as "show in navigation".

0 votesVote for this answer Mark as a Correct answer

Joshua Adams answered on July 23, 2014 15:40

What is in your where clause?

0 votesVote for this answer Mark as a Correct answer

Mateusz Żebrowski answered on July 24, 2014 08:26

DocumentMenuItemHideInNavigation = 0 OR DocumentMenuItemHideInNavigation = 1

I've tried also with brackets.

0 votesVote for this answer Mark as a Correct answer

Joshua Adams answered on July 24, 2014 14:56

Your where clause is saying to bring the document in either way...the field is set to a boolean/bit, so by you having 0 OR 1, its bringing in all of the documents. Try to take out the 0 part of the clause. If you want it just to pull in items that are hidden from the navigation, you would have DocumentMenuItemHideInNavigation = 1 , otherwise, you would want all items that are not hidden from the navigation, which would be DocumentMenuItemHideInNavigation = 0.

0 votesVote for this answer Mark as a Correct answer

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