1 Here are some tips for ways to style the links
2 provided by the [[plugins/parentlinks]] plugin.
4 This plugin offers a `HTML::Template` loop that iterates over all or
5 a subset of a page's parents. It also provides a few bonus
6 possibilities, such as styling the parent links depending on their
14 The plugin provides one template loop, called `PARENTLINKS`, that
15 returns the list of parent pages for the current page. Every returned
16 path element has the following variables set:
18 * `URL` (string): url to the current path element
19 * `PAGE` (string): title of the current path element
20 * `DEPTH` (positive integer): depth of the path leading to the
21 current path element, counting from the wiki's root, which has
23 * `HEIGHT` (positive integer): distance, expressed in path elements,
24 from the current page to the current path element; e.g. this is
25 1 for the current page's mother, 2 for its grand-mother, etc.
26 * `DEPTH_n` (boolean): true if, and only if, `DEPTH==n`
27 * `HEIGHT_n` (boolean): true if, and only if, `HEIGHT==n`
32 The `DEPTH_n` and `HEIGHT_n` variables allow the template writer to
33 skip arbitrary elements in the parents list: they are arbitrary
36 The `DEPTH` and `HEIGHT` variables allow the template writer to apply
37 general treatment, depending on one of these variables, to *every*
38 parent: they are counters.
43 As in the default `page.tmpl`, one can simply display the list of
46 <TMPL_LOOP NAME="PARENTLINKS">
47 <a href="<TMPL_VAR NAME=URL>"><TMPL_VAR NAME=PAGE></a>/
52 Styling parents depending on their depth
53 ----------------------------------------
55 Say you want the parent links to be styled depending on their depth in
56 the path going from the wiki root to the current page; just add the
57 following lines in `page.tmpl`:
59 <TMPL_LOOP NAME="PARENTLINKS">
60 <a href="<TMPL_VAR NAME="URL">" class="depth<TMPL_VAR NAME="DEPTH">">
61 <TMPL_VAR NAME="PAGE">
65 Then write the appropriate CSS bits for `a.depth1`, etc.
67 Skip some parents, style the others depending on their distance to the current page
68 -----------------------------------------------------------------------------------
70 Say you want to display all the parents links but the wiki homepage,
71 styled depending on their distance to the current page; just add the
72 following lines in `page.tmpl`:
74 <TMPL_LOOP NAME="PARENTLINKS">
75 <TMPL_IF NAME="DEPTH_0">
77 <a href="<TMPL_VAR NAME="URL">" class="height<TMPL_VAR NAME="HEIGHT">">
78 <TMPL_VAR NAME="PAGE">
82 Then write the appropriate CSS bits for `a.height1`, etc.
87 Let's have a look at a more complicated example; combining the boolean
88 loop variables provided by the plugin (`IS_ROOT` and friends) and
89 `HTML::Template` flow control structures, you can have custom HTML
90 and/or CSS generated for some special path components; e.g.:
92 <!-- all parents, skipping mother and grand'ma, inside a common div+ul -->
93 <div id="oldestparents">
95 <TMPL_LOOP NAME="PARENTLINKS">
96 <TMPL_IF NAME="HEIGHT_2">
98 <TMPL_IF NAME="HEIGHT_1">
100 <li><a href="<TMPL_VAR NAME="URL">"><TMPL_VAR NAME="PAGE"></a></li>
107 <!-- dedicated div's for mother and grand'ma -->
108 <TMPL_LOOP NAME="PARENTLINKS">
109 <TMPL_IF NAME="HEIGHT_2">
111 <a href="<TMPL_VAR NAME="URL">"><TMPL_VAR NAME="PAGE"></a>
114 <TMPL_IF NAME="HEIGHT_1">
116 <a href="<TMPL_VAR NAME="URL">"><TMPL_VAR NAME="PAGE"></a>
122 <!-- eventually, the current page title -->
123 <TMPL_VAR NAME="TITLE">