Wiki source code of Programming

Version 14.6 by Vincent Massol on 2017/09/07

Show last authors
1 Bored of simple text in your pages? Are you interested in giving life to your wiki? Then you can make use of XWiki's powerful programming API directly from your wiki pages. XWiki offers support for [[several scripting languages: **Velocity**, **Groovy**, **Python**, **Ruby** and even **PHP**>>platform:DevGuide.Scripting]].
2
3 XWiki exposes APIs that allows you to manipulate the wiki and its pages easily.
4
5 To whet your appetite simply put the following code in your page:
6
7 {{code language="none"}}
8 {{velocity}}
9 #set($query = "where doc.parent is null or doc.parent='' order by doc.name asc")
10
11 #foreach($item in $services.query.xwql($query).execute())
12 #set($orphanedDoc = $xwiki.getDocument($item))
13 * [[$orphanedDoc.displayTitle>>$orphanedDoc]] (located in space //$orphanedDoc.space//, contains $orphanedDoc.attachmentList.size() attachments)
14 #end
15 {{/velocity}}
16 {{/code}}
17
18 You'll get a list of orphaned pages (i.e. pages that have no parent). For example:
19
20 {{image reference="velocityexampleresult.png"/}}
21
22 Check the **[[Developer's Guide>>platform:DevGuide.WebHome]]** and especially the **[[XWiki Scripting section>>platform:DevGuide.Scripting]]** to learn more.
23
24 You might also want to check out the **[[Snippets wiki>>snippets:Main.WebHome]]** which contains a lot of code snippets that you can reuse in your pages. And you can also check the **[[Extensions wiki>>extensions:Main.WebHome]]** to install ready-to-use extensions built using these mechanisms.

Get Connected