]> sipb.mit.edu Git - ikiwiki.git/blob - doc/plugins/contrib/sidebar2.mdwn
Merge branch 'master' into spalax
[ikiwiki.git] / doc / plugins / contrib / sidebar2.mdwn
1 [[!meta author="spalax"]]
2 [[!template id=plugin name=sidebar2 author="[[Louis|spalax]]"]]
3 [[!tag type/chrome]]
4
5 *Claim:* The [[sidebar|plugins/sidebar]] plugin has nothing
6 to do with sidebars. This plugin renders some page (which happens to be named
7 `sidebar`) and put the result in template variable `SIDEBAR` of template
8 `page.tmpl`. But the fact that it is a sidebar, i.e. a bar appearing on the
9 side on the screen, is done by CSS.
10
11 What if I want a sidebar, and a [[navigation bar|plugins/contrib/navbar]], and
12 a footer a bit more elaborated than the one in the template, etc.? This plugin
13 allows this.
14
15 # Configuration
16
17 If no option is given, or if option `global_sidebars` is a boolean, this plugin
18 is identical to the [[sidebar plugin|plugins/sidebar/]] (if not, please [report
19 a bug](https://atelier.gresille.org/projects/gresille-ikiwiki/issues)).
20 Otherwise, `global_sidebars` is a list of sidebars to include. The list is as
21 follow:
22
23     global_sidebars => [
24       "var1", "page1", "pagespec1",
25       "var2", "page2", "pagespec2",
26       ]
27
28 The meaning is: if available, render `page1` in pages matching `pagespec1`, and
29 put it in variable `var1` of the page template, and so on for `var2`, `page2`,
30 etc.
31
32 The default, which gives the behaviour of the sidebar plugin, is
33 `global_sidebars => ["sidebar", "sidebar", "*"]`.
34
35 *Remark: It would be more sensible to have a list of lists, as the following example, but I did not manage to do so because of [[this bug|bugs/structured_config_data_is_mangled]].*
36
37     global_sidebars => [
38       ["var1", "page1", "pagespec1"],
39       ["var2", "page2", "pagespec2"],
40       ]
41
42 # Improvements over sidebar plugin
43
44 * You can add several "sidebars" to your wiki. For example, to have a sidebar, a submenu that appears only in documentation pages (`doc/*`), and a footer, your `global_sidebars` would be:
45
46       global_sidebars => [
47         "sidebar", "sidebar", "*",
48         "menu", "/doc/menu", "doc/*",
49         "footer", "/footer", "*"
50         ]
51
52 * You can enable sidebars only in certain pages matching the pagespec. If, for
53   the same template variable, several pagespec match the current page, the
54   first page in the list is taken into account.
55
56   For example, the following configuration says: render `menu` as the sidebar
57   for every page, excepted subpages of `doc`, for which the `doc_menu` page
58   should be rendered.
59
60       global_sidebars => [
61         "sidebar", "doc_menu", "doc/*",
62         "sidebar", "menu", "*",
63         ]
64
65 # Directive
66
67 The behaviour of the `sidebar` directive is similar to the directive of the
68 original [[sidebar|plugins/sidebar]], excepted that a new `var` argument is
69 available.
70
71 If this `var` argument is set, instead of applying to the default `sidebar`
72 template variable, the directive applies to the value given in the argument.
73
74 For example, the following command forces the `footer` sidebar to appear on the
75 current page.
76
77     \[[!sidebar var=footer]]
78
79 The following command forces the `footer` sidebar to appaer, containing the
80 content given in argument.
81
82     \[[!sidebar var=footer content="TEST"]]
83
84 # Which pages to render?
85
86 Here is the decision process to decide what is rendered in a template variable
87 handled by this plugin.
88
89 1. If the page contains the [[sidebar|ikiwiki/directive/sidebar]] directive, with a `content` argument, this content is rendered.
90 2. If the page contains the [[sidebar|ikiwiki/directive/sidebar]] directive with no `content` argument, the first rule for the considered template variable is applied, disregarding the pagespec.
91 3. If none of the above, the first rule having its pagespec patching the current page is applied.
92 4. If none of the above, the variable is left empty.
93
94 # Download and install
95
96 Code and documentation: [[https://atelier.gresille.org/projects/gresille-ikiwiki/wiki/Sidebar2]].