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:

  1. Make sure your administrator gives you programming rights.
  2. Edit the page using the Wiki editor.
  3. 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}}
  4. Save the page.
  5. Notice how the page now renders a bulleted list of orphaned documents, each showing its space and attachment count:

    example-velocity.png

Get Connected