List Orphaned Pages Using a Velocity Script
Last modified by Eleni Cojocariu on 2026/07/13 23:46
Content
Steps
To display a list of orphaned pages (pages with no parent) using a Velocity script:
- Make sure your administrator gives you programming rights.
- Edit the page using the Wiki editor.
- Add the following code to the page content:
{{velocity}} #set($query = "where doc.parent is null or doc.parent='' order by doc.name asc") #foreach($item in $services.query.xwql($query).execute()) #set($orphanedDoc = $xwiki.getDocument($item)) * [[$orphanedDoc.displayTitle>>$orphanedDoc]] (located in //$orphanedDoc.space//, contains $orphanedDoc.attachmentList.size() attachments) #end {{/velocity}} - Save the page.
- Notice how the page now renders a bulleted list of orphaned documents, each showing its space and attachment count:
