]> sipb.mit.edu Git - ikiwiki.git/blob - doc/plugins/conditional.mdwn
Use non-deprecated wikilink page (ikiwiki/wikilink)
[ikiwiki.git] / doc / plugins / conditional.mdwn
1 [[!template id=plugin name=conditional core=1 author="[[Joey]]"]]
2 [[!tag type/format]]
3
4 With this plugin, you can make text be conditionally displayed on a page.
5 For example:
6
7         \[[!if test="enabled(smiley)"
8               then="The smiley plugin is enabled :-)"
9               else="No smiley plugin here.."]]
10
11 If the specified `test` succeeds, the `then` text will be displayed,
12 otherwise the `else` text will be displayed. The `else` part is optional.
13
14 The `then` and `else` values can include any markup that would be allowed
15 in the wiki page outside the template. Triple-quoting the values even allows
16 quotes to be included.
17
18 The `test` is a [[ikiwiki/PageSpec]]; if it matches any page in the wiki
19 then it succeeds. So you can do things like testing for the existence of a
20 page or pages, testing to see if any pages were created in a given month,
21 and so on.
22
23 If you want the [[ikiwiki/PageSpec]] to only match against the page that
24 contains the conditional, rather than matching against all pages in the
25 wiki, set the "all" parameter to "no".
26
27 The regular [[ikiwiki/PageSpec]] syntax is expanded with the following
28 additional tests:
29
30 * enabled(plugin)
31
32   Tests whether the specified plugin is enabled.
33
34 * sourcepage(glob)
35
36   Tests whether the glob matches the name of the page that contains the
37   conditional.
38
39 * destpage(glob)
40
41   Tests whether the glob matches the name of the page that is being built.
42   That might be different than the name of the page that contains the
43   conditional, if it's being inlined into another page.
44
45 * included()
46
47   Tests whether the page is being included onto another page.