Wiki source code of User Cookbook

Last modified by Vincent Massol on 2017/09/05 11:09

Hide last authors
krokosjablik 1.1 1 {{toc numbered="false" depth="2"/}}
2
Vincent Massol 9.1 3 If you have a great recipe ([[How-to>>http://en.wikipedia.org/wiki/How-to]]), share with other chefs ! Please consider our [[Guidelines>>||anchor="HGuidelinesforaddingnewrecipes"]] below.
krokosjablik 5.1 4
5
krokosjablik 4.1 6 = Guidelines for adding new recipes =
Vincent Massol 7.2 7
krokosjablik 4.1 8 * a recipe should be placed here only if it is ready for that, best create a [[Draft>>Drafts.WebHome]] at first
9 * the new syntax "xwiki-2.0" should be prefered
10 * before every recipe an info box should be placed like that:
Vincent Massol 7.2 11 {{code}}{{info}} The recipe is valid for:
krokosjablik 4.1 12 * XWiki versions: 1.9+, 2.0+
13 * Wiki syntax: xwiki-2.0
Vincent Massol 7.2 14 {{/info}}{{/code}}
krokosjablik 1.1 15
16 = Translations =
17
krokosjablik 5.1 18 == How can I translate panels? ==
krokosjablik 1.1 19
Vincent Massol 7.2 20 {{info}}
21 The recipe is valid for:
krokosjablik 5.1 22 * XWiki versions: 2.0+
23 * Wiki syntax: xwiki-2.0
24 {{/info}}
25
26 Currently xwiki doesn't support translation for panels natively, therefore the following workarounds should help you.
27
28 === With Velocity scripting ===
Vincent Massol 7.2 29
krokosjablik 7.1 30 Put the following velocity script into your panel and replace language codes with [[yours>> http://platform.xwiki.org/xwiki/bin/view/Features/I18N]] ('elseif'-Blocks can be repeated unlimited times!):
Vincent Massol 7.2 31 {{code}}{{velocity}}
krokosjablik 1.1 32 #panelheader('MyPanel')
33 #if ($context.language == "de")
34 My German translation
35 #elseif ($context.language == "fr")
36 My French translation
37 #else
38 My default translation
39 #end
40 #panelfooter()
Vincent Massol 7.2 41 {{/velocity}}{{/code}}
krokosjablik 1.1 42
krokosjablik 7.1 43
krokosjablik 5.1 44 === With translated pages ===
krokosjablik 1.1 45
Vincent Massol 7.2 46 {{warning}}
Vincent Massol 9.3 47 Maybe the macro "includeForm()" is not the best choice here, see [[including macros>>xwiki:FAQ.IncludeInVelocity]]. Please improve this recipe if you know it better.
Vincent Massol 7.2 48 {{/warning}}
49
krokosjablik 5.1 50 1. Create a new wiki page, for example 'Main.MyMenu'
51 1. [[Translate>>http://platform.xwiki.org/xwiki/bin/view/Features/I18N#HEditatranslation]] it
krokosjablik 1.1 52 1. Include this page in your panel, for example:
Vincent Massol 7.2 53 {{code}}{{velocity}}
krokosjablik 1.1 54 #panelheader('MyPanel')
55 #includeForm('Main.MyMenu')
56 #panelfooter()
Vincent Massol 7.2 57 {{/velocity}}{{/code}}
krokosjablik 1.1 58
krokosjablik 5.1 59 = How can I check user rights? =
krokosjablik 1.1 60
Vincent Massol 7.2 61 {{info}}
62 The recipe is valid for:
krokosjablik 5.1 63 * XWiki versions: 2.0+
64 * Wiki syntax: xwiki-2.0
65 {{/info}}
krokosjablik 1.1 66
67 == Check admin rights ==
Vincent Massol 7.2 68
krokosjablik 1.1 69 {{code}}
70 {{velocity}}
71 #if ($xwiki.hasAdminRights())
72 The current user has admin rights
73 #end
74 {{/velocity}}
75 {{/code}}
76
77 == Check edit rights ==
Vincent Massol 7.2 78
krokosjablik 1.1 79 {{code}}
80 {{velocity}}
81 #if($hasEdit)
82 The current user has edit rights
83 #end
84 {{/velocity}}
85 {{/code}}

Get Connected