User Cookbook

Last modified by Roman Friesen on 2009/10/13 12:49

If you have a great recipe (How-to), share with other chefs emoticon_wink! 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?

 The recipe is valid for:

  • XWiki versions: 2.0+
  • Wiki syntax: xwiki-2.0

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

Maybe the macro "includeForm()" is not the best choice here, see including macros. Please improve this recipe if you know it better.
  1. Create a new wiki page, for example 'Main.MyMenu'
  2. Translate it
  3. Include this page in your panel, for example:
    {{velocity}}
    #panelheader('MyPanel')
    #includeForm('Main.MyMenu')
    #panelfooter()
    {{/velocity}}

How can I check user rights?

 The recipe is valid for:

  • XWiki versions: 2.0+
  • Wiki syntax: xwiki-2.0

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}}
Tags:
Created by Roman Friesen on 2009/09/27 10:39

Get Connected