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">
83 Then write the appropriate CSS bits for `a.height1`, etc.
85 Avoid showing title of toplevel index page
86 ------------------------------------------
88 If you don't like having "index" appear on the top page of the wiki,
89 but you do want to see the name of the page otherwise, you can use a
90 special `HAS_PARENTLINKS` template variable that the plugin provides.
91 It is true for every page *except* the toplevel index.
93 Here is an example of using it to hide the title of the toplevel index
96 <TMPL_LOOP NAME="PARENTLINKS">
97 <a href="<TMPL_VAR NAME=URL>"><TMPL_VAR NAME=PAGE></a>/
99 <TMPL_IF HAS_PARENTLINKS>
106 Let's have a look at a more complicated example; combining the boolean
107 loop variables provided by the plugin (`IS_ROOT` and friends) and
108 `HTML::Template` flow control structures, you can have custom HTML
109 and/or CSS generated for some special path components; e.g.:
111 <!-- all parents, skipping mother and grand'ma, inside a common div+ul -->
112 <div id="oldestparents">
114 <TMPL_LOOP NAME="PARENTLINKS">
115 <TMPL_IF NAME="HEIGHT_2">
117 <TMPL_IF NAME="HEIGHT_1">
119 <li><a href="<TMPL_VAR NAME="URL">"><TMPL_VAR NAME="PAGE"></a></li>
126 <!-- dedicated div's for mother and grand'ma -->
127 <TMPL_LOOP NAME="PARENTLINKS">
128 <TMPL_IF NAME="HEIGHT_2">
130 <a href="<TMPL_VAR NAME="URL">"><TMPL_VAR NAME="PAGE"></a>
133 <TMPL_IF NAME="HEIGHT_1">
135 <a href="<TMPL_VAR NAME="URL">"><TMPL_VAR NAME="PAGE"></a>
141 <!-- eventually, the current page title -->
142 <TMPL_VAR NAME="TITLE">