5 I may have missed a simple way to achieve what I need without
6 modifying ikiwiki, so here is the context.
8 I have a first-level directory (called `bricks`) containing a bunch of
19 I have two groups of tags called `direction` and `usage`, stored in
20 two sub-directories of `$tagbase` :
34 Any page in `/brick` can be tagged with one or more tags from any of
37 I need to present different views for these wiki pages, so a `/view`
38 tree is dedicated to this mission :
52 ... where e.g. `/view/dev/d1` lists a subset (depending on other tags)
53 of the pages tagged d1.
57 - thanks to the edittemplate plugin, `/view/dev/*` and `/view/howto/*` would contain respectively `\[[template id=dev_direction]]` and `\[[template id=howto_usage]]`
58 - `/templates/dev_direction.mdwn` and `/templates/howto_usage.mdwn` would use `\[[!map ...]]` directives to build their views
62 Such map directives would look something like the following (more
63 complicated, actually, but let's focus on my current issue) :
65 \[[!map pages="bricks/* and link(tag/usage/<TMPL_VAR BASENAME>)"]]
67 Where `BASENAME` value would be, e.g., `u1` or `d2`, depending on the
68 page inserting the template. But `BASENAME` does not exist. I found
69 that `<TMPL_VAR PAGE>` is replaced with the full path to the page, but
70 I did not found how to get the page's basename in a template included
71 with a `\[[template id=...]]` directive.
75 I guess it would be possible to provide the templates inserted by the
76 template plugin with more `TMPL_VAR` variables, but I don't know ikiwiki
77 codebase well, so I don't know how hard it would be.
79 I sure could write a ad-hoc plugin that would use the pagetemplate
80 hook to add a custom `<TMPL_LOOP>` selector I could use in my
81 templates, or another one that would use the filter hook to add the
82 needed `\[[!map ...]]` where it belongs to, but since ikiwiki's
83 preprocessor directives already *almost* do what I need, I'd like to
84 avoid the ad-hoc plugin solution.
86 (Adding a parameter such as `name=d1` in every `/view/dev/d*.mdwn` and
87 `/view/howto/u*.mdwn` page is not an option : I want to factorize the
88 most possible of these pages.
90 > The following patch adds a `basename` `TMPL_VAR` variable that can be
91 > used in the templates inserted by \[[template plugin]] :
93 > diff --git a/IkiWiki/Plugin/template.pm b/IkiWiki/Plugin/template.pm
94 > index a6e34fc..bb9dd8d 100644
95 > --- a/IkiWiki/Plugin/template.pm
96 > +++ b/IkiWiki/Plugin/template.pm
97 > @@ -57,6 +57,8 @@ sub preprocess (@) { #{{{
101 > + $template->param("basename" => (split("/", $params{page}))[-1]);
103 > return IkiWiki::preprocess($params{page}, $params{destpage},
104 > IkiWiki::filter($params{page}, $params{destpage},
105 > $template->output));
109 > Thanks for taking the trouble to develop a patch. [[done]] --[[Joey]]
111 >> Thanks :) -- intrigeri