Wiki source code of Programming

Last modified by Vincent Massol on 2024/01/15

Hide last authors
Vincent Massol 15.2 1 Bored with plain text on your pages? Interested in bringing your wiki to life? Then you can use XWiki's powerful programming API right from your wiki pages. XWiki comes with support for [[several scripting languages: **Velocity**, **Groovy**, **Python**, **Ruby**, and even **PHP**>>Documentation.DevGuide.Scripting]].
Vincent Massol 1.1 2
Vincent Massol 15.2 3 XWiki exposes APIs that allow you to easily manipulate the wiki and its pages.
Vincent Massol 1.1 4
Vincent Massol 15.2 5 To whet your appetite, simply add the following code to your page:
Vincent Massol 1.2 6
Vincent Massol 8.3 7 {{code language="none"}}
Guillaume Lerouge 7.1 8 {{velocity}}
Vincent Massol 1.21 9 #set($query = "where doc.parent is null or doc.parent='' order by doc.name asc")
Vincent Massol 1.2 10
Vincent Massol 10.1 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)
Vincent Massol 1.21 14 #end
Guillaume Lerouge 7.1 15 {{/velocity}}
Silvia Macovei 5.1 16 {{/code}}
psa 1.8 17
Manuel Smeria 9.3 18 You'll get a list of orphaned pages (i.e. pages that have no parent). For example:
Vincent Massol 1.2 19
Silvia Macovei 8.5 20 {{image reference="velocityexampleresult.png"/}}
Vincent Massol 1.2 21
Thomas Mortagne 15.1 22 Check the **[[Developer's Guide>>Documentation.DevGuide.WebHome]]** and especially the **[[XWiki Scripting section>>Documentation.DevGuide.Scripting]]** to learn more.
Silvia Macovei 8.2 23
Vincent Massol 15.2 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 out the **[[Extensions wiki>>extensions:Main.WebHome]]** to install ready-to-use extensions built using these mechanisms.

Get Connected