User Cookbook
Last modified by Vincent Massol on 2017/09/05 11:09
If you have a great recipe (How-to), share with other chefs ! Please consider our Guidelines below.
Guidelines for adding new recipes
- a recipe should be placed here only if it is ready for that, best create a Draft at first
- the new syntax "xwiki-2.0" should be prefered
- before every recipe an info box should be placed like that:
{{info}} The recipe is valid for: * XWiki versions: 1.9+, 2.0+ * Wiki syntax: xwiki-2.0 {{/info}}
Translations
How can I translate panels?
Currently xwiki doesn't support translation for panels natively, therefore the following workarounds should help you.
With Velocity scripting
Put the following velocity script into your panel and replace language codes with yours ('elseif'-Blocks can be repeated unlimited times!):{{velocity}}
#panelheader('MyPanel')
#if ($context.language == "de")
My German translation
#elseif ($context.language == "fr")
My French translation
#else
My default translation
#end
#panelfooter()
{{/velocity}}
With translated pages
- Create a new wiki page, for example 'Main.MyMenu'
- Translate it
- Include this page in your panel, for example:
{{velocity}} #panelheader('MyPanel') #includeForm('Main.MyMenu') #panelfooter() {{/velocity}}
How can I check user rights?
Check admin rights
{{velocity}}
#if ($xwiki.hasAdminRights())
The current user has admin rights
#end
{{/velocity}}Check edit rights
{{velocity}}
#if($hasEdit)
The current user has edit rights
#end
{{/velocity}}