1 [[!template id=plugin name=pedigree author="intrigeri"]]
4 This plugin offers a `HTML::Template` loop that iterates over all or
5 a subset of a page's parents, providing a few bonus possibilities,
6 such as styling the parent links depending on their place in the path.
7 One can think of pedigree as "`PARENTLINKS` on steroids".
14 This plugin provides one template loop, called `PEDIGREE`, that
15 returns the same parents list as `PARENTLINKS` would; as a bonus,
16 every path element returned by the `PEDIGREE` loop has the following
19 * `URL` (string): url to the current path element
20 * `PAGE` (string): title of the current path element
21 * `DEPTH` (positive integer): depth of the path leading to the
22 current path element, counting from the wiki's root, which has
24 * `HEIGHT` (positive integer): distance, expressed in path elements,
25 from the current page to the current path element; e.g. this is
26 1 for the current page's mother, 2 for its grand-mother, etc.
27 * `DEPTH_n` (boolean): true if, and only if, `DEPTH==n`
28 * `HEIGHT_n` (boolean): true if, and only if, `HEIGHT==n`
33 The `DEPTH_n` and `HEIGHT_n` variables allow the template writer to
34 skip arbitrary elements in the parents list: they are arbitrary
37 The `DEPTH` and `HEIGHT` variables allow the template writer to apply
38 general treatment, depending on one of these variables, to *every*
39 parent: they are counters.
41 Styling parents depending on their depth
42 ----------------------------------------
44 Say you want the parent links to be styled depending on their depth in
45 the path going from the wiki root to the current page; just add the
46 following lines in `page.tmpl`:
48 <TMPL_LOOP NAME="PEDIGREE">
49 <a href="<TMPL_VAR NAME="URL">" class="depth<TMPL_VAR NAME="DEPTH">">
50 <TMPL_VAR NAME="PAGE">
54 Then write the appropriate CSS bits for `a.depth1`, etc.
56 Skip some parents, style the others depending on their distance to the current page
57 -----------------------------------------------------------------------------------
59 Say you want to display all the parents links but the wiki homepage,
60 styled depending on their distance to the current page; just add the
61 following lines in `page.tmpl`:
63 <TMPL_LOOP NAME="PEDIGREE">
64 <TMPL_IF NAME="DEPTH_0">
66 <a href="<TMPL_VAR NAME="URL">" class="height<TMPL_VAR NAME="HEIGHT">">
67 <TMPL_VAR NAME="PAGE">
71 Then write the appropriate CSS bits for `a.height1`, etc.
76 Let's have a look at a more complicated example; combining the boolean
77 loop variables provided by this plugin (`IS_ROOT` and friends) and
78 `HTML::Template` flow control structures, you can have custom HTML
79 and/or CSS generated for some special path components; e.g.:
81 <!-- all parents, skipping mother and grand'ma, inside a common div+ul -->
82 <div id="oldestparents">
84 <TMPL_LOOP NAME="PEDIGREE">
85 <TMPL_IF NAME="HEIGHT_2">
87 <TMPL_IF NAME="HEIGHT_1">
89 <li><a href="<TMPL_VAR NAME="URL">"><TMPL_VAR NAME="PAGE"></a></li>
96 <!-- dedicated div's for mother and grand'ma -->
97 <TMPL_LOOP NAME="PEDIGREE">
98 <TMPL_IF NAME="HEIGHT_2">
100 <a href="<TMPL_VAR NAME="URL">"><TMPL_VAR NAME="PAGE"></a>
103 <TMPL_IF NAME="HEIGHT_1">
105 <a href="<TMPL_VAR NAME="URL">"><TMPL_VAR NAME="PAGE"></a>
111 <!-- eventually, the current page title -->
112 <TMPL_VAR NAME="TITLE">