Macro: join multiple document listings as ONE listing

Rita Mikusch asked on August 27, 2020 00:27

Hi, Here's the macro we're currently using to retrieve data for a PAGE TYPE radio button field:

Documents["/Site-Settings/NVKB-Branches"].Children.WithAllData#

It works beautifully ... but we actually want to retrieve data from MULTIPLE different areas in the PAGES application ... and have them all appear as options for that one single radio button field.

How we rewrite this, so all these items will appear TOGETHER as ONE data list for that one single radio button field?

Documents["/Site-Settings/NVKB-Branches"].Children.WithAllData#

Documents["/Site-Settings/NEWS-Branches"].Children.WithAllData#

Documents["/Site-Settings/MORESTUFF-Branches"].Children.WithAllData#

Thank you! Rita.

Correct Answer

Dmitry Bastron answered on August 27, 2020 10:54

Hi Rita,

You can try the following macro:

Documents.Where("NodeAliasPath like '/Site-Settings/NVKB-Branches/%' or NodeAliasPath like '/Site-Settings/NEWS-Branches/%' or NodeAliasPath like '/Site-Settings/MORESTUFF-Branches'").WithAllData

But this will return not only direct children of your nodes but all their children (like if you have substituted .Children with .AllChildren in your queries). But if you need children only direct children (not from all levels), you can still do it by adding NodeLevel parameter to your query:

Documents.Where("(NodeAliasPath like '/Site-Settings/NVKB-Branches/%' and NodeLevel=3) or (NodeAliasPath like '/Site-Settings/NEWS-Branches/%' and NodeLevel=3) or (NodeAliasPath like '/Site-Settings/MORESTUFF-Branches/%' and NodeLevel=3)").WithAllData
1 votesVote for this answer Unmark Correct answer

Recent Answers


Juraj Ondrus answered on August 27, 2020 10:46

If the pages are the same page type, what about getting all pages of given page type from the tree? Something like Documents.ClassNames("CMS.News").WithAllData["/"].

Or, using WHERE condition: Documents[Documents.Where("NodeClassID = <someID>")....

0 votesVote for this answer Mark as a Correct answer

Rita Mikusch answered on August 27, 2020 21:43

Thank you for both the ideas, much appreciated :).

0 votesVote for this answer Mark as a Correct answer

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