List Orphaned Pages Using a Velocity Script

Last modified by superadmin on 2026/11/25 21:39

Content

A wiki page that lists every page with no parent, generated by a short Velocity script.

Steps

  1. Make sure your administrator gives you programming rights.
  2. Edit the page using the Wiki editor.
  3. Add the following Velocity script, which lists the pages with no parent, 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:

    The result displaying the list of pages with no parent

Get Connected