Create List off of content tree

John Walter asked on August 26, 2015 21:55

Hi, Anyone have a good idea for using a macro to insert a list of pages based on the child documents of a directory? In other words, I want a bulleted list of links to all the pages within a specified directory that updates automatically when I add or remove a page from that directory.


Correct Answer

Jim Spillane answered on August 26, 2015 22:39

Hi John. You can try something like this

foreach (x in CurrentDocument.Children)
  println("<li><a href=\"" + x.NodeAliasPath + "\">" + x.DocumentName + "</a></li>");
1 votesVote for this answer Unmark Correct answer

Recent Answers

Roman Hutnyk answered on August 26, 2015 23:07 (last edited on August 26, 2015 23:09)


Where would you like to add that list of child pages?

If the answer is to a page, than repeater web part, or any other from Listing and Viewers section, will do this for you, unless I'm missing what your goal is.

In the repeater web part you can specify the path to show pages within (either static or macro), and transformation, along with other settings. In your transformation you can get a link with either GetDocumentLink or GetDocumentUrl methods. Find more methods here.

This will result in a page listing, which will change anytime new item has been created under the specified path.

0 votesVote for this answer Mark as a Correct answer

John Walter answered on August 27, 2015 17:00 (last edited on August 27, 2015 17:40)

0 votesVote for this answer Mark as a Correct answer

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