Last modified by Eleni Cojocariu on 2026/08/26 17:33

Show last authors
1 To display a list of orphaned pages ([[pages with no parent>>doc:documentation.xs.user.base.page.nested-pages.relations.WebHome]]) using a [[Velocity script>>doc:Documentation.DevGuide.Scripting.XWikiVelocityTraining.WebHome]]:
2
3 1. Make sure your administrator gives you [[programming rights>>documentation.xs.admin.rights.right-types.WebHome]].
4 1. [[Edit the page using the Wiki editor>>doc:documentation.xs.user.base.page.edit-page.edit-wiki-editor.WebHome]].
5 1. Add the following code to the page content:(((
6 {{code language="velocity"}}
7 {{velocity}}
8 #set($query = "where doc.parent is null or doc.parent='' order by doc.name asc")
9
10 #foreach($item in $services.query.xwql($query).execute())
11 #set($orphanedDoc = $xwiki.getDocument($item))
12 * [[$orphanedDoc.displayTitle>>$orphanedDoc]] (located in //$orphanedDoc.space//, contains $orphanedDoc.attachmentList.size() attachments)
13 #end
14 {{/velocity}}
15 {{/code}}
16 )))
17 1. Save the page.
18 1. Notice how the page now renders a bulleted list of orphaned documents, each showing its space and attachment count:(((
19 {{image reference="example-velocity.png" size="large" alt="The result displaying the list of pages with no parent"/}}
20 )))

Get Connected