Wiki source code of User Cookbook
Last modified by Vincent Massol on 2017/09/05 11:09
Hide last authors
| author | version | line-number | content |
|---|---|---|---|
| |
1.1 | 1 | {{toc numbered="false" depth="2"/}} |
| 2 | |||
![]() |
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. |
| |
5.1 | 4 | |
| 5 | |||
| |
4.1 | 6 | = Guidelines for adding new recipes = |
![]() |
7.2 | 7 | |
| |
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: | ||
![]() |
7.2 | 11 | {{code}}{{info}} The recipe is valid for: |
| |
4.1 | 12 | * XWiki versions: 1.9+, 2.0+ |
| 13 | * Wiki syntax: xwiki-2.0 | ||
![]() |
7.2 | 14 | {{/info}}{{/code}} |
| |
1.1 | 15 | |
| 16 | = Translations = | ||
| 17 | |||
| |
5.1 | 18 | == How can I translate panels? == |
| |
1.1 | 19 | |
![]() |
7.2 | 20 | {{info}} |
| 21 | The recipe is valid for: | ||
| |
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 === | ||
![]() |
7.2 | 29 | |
| |
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!): |
![]() |
7.2 | 31 | {{code}}{{velocity}} |
| |
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() | ||
![]() |
7.2 | 41 | {{/velocity}}{{/code}} |
| |
1.1 | 42 | |
| |
7.1 | 43 | |
| |
5.1 | 44 | === With translated pages === |
| |
1.1 | 45 | |
![]() |
7.2 | 46 | {{warning}} |
![]() |
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. |
![]() |
7.2 | 48 | {{/warning}} |
| 49 | |||
| |
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 | ||
| |
1.1 | 52 | 1. Include this page in your panel, for example: |
![]() |
7.2 | 53 | {{code}}{{velocity}} |
| |
1.1 | 54 | #panelheader('MyPanel') |
| 55 | #includeForm('Main.MyMenu') | ||
| 56 | #panelfooter() | ||
![]() |
7.2 | 57 | {{/velocity}}{{/code}} |
| |
1.1 | 58 | |
| |
5.1 | 59 | = How can I check user rights? = |
| |
1.1 | 60 | |
![]() |
7.2 | 61 | {{info}} |
| 62 | The recipe is valid for: | ||
| |
5.1 | 63 | * XWiki versions: 2.0+ |
| 64 | * Wiki syntax: xwiki-2.0 | ||
| 65 | {{/info}} | ||
| |
1.1 | 66 | |
| 67 | == Check admin rights == | ||
![]() |
7.2 | 68 | |
| |
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 == | ||
![]() |
7.2 | 78 | |
| |
1.1 | 79 | {{code}} |
| 80 | {{velocity}} | ||
| 81 | #if($hasEdit) | ||
| 82 | The current user has edit rights | ||
| 83 | #end | ||
| 84 | {{/velocity}} | ||
| 85 | {{/code}} |
