How to get PageIds of all child pages in a folder programatically

Novice User asked on January 4, 2018 17:34

How to get all page Ids of child pages inside a folder

Correct Answer

Lee Conlin answered on January 4, 2018 18:17

This should get you there.

var pageIds = DocumentHelper.GetDocuments()
    .Select(x => x.DocumentID)
1 votesVote for this answer Unmark Correct answer

Recent Answers

Novice User answered on January 4, 2018 18:31 (last edited on January 4, 2018 18:54)

Above code threw this exception

'CMS.DataEngine.InfoDataSet<CMS.DocumentEngine.TreeNode>' does not contain a definition for 'Select' and no extension method 'Select' accepting a first argument of type 'CMS.DataEngine.InfoDataSet<CMS.DocumentEngine.TreeNode>' could be found (are you missing a using directive or an assembly reference?

But below alteration worked for me .

 var pageIds = DocumentHelper.GetDocuments().Path("/folder path/%")                    

    foreach (var document in pageIds)
        Response.Write(HTMLHelper.HTMLEncode(document.DocumentID.ToString()) + "<br />");


0 votesVote for this answer Mark as a Correct answer

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