]> sipb.mit.edu Git - ikiwiki.git/blob - doc/todo/Give_access_to_more_TMPL__95__VAR_variables_in_templates_inserted_by_the_template_plugin.mdwn
6f430975e30521dd6ab1a5101e8fef69c02cc20b
[ikiwiki.git] / doc / todo / Give_access_to_more_TMPL__95__VAR_variables_in_templates_inserted_by_the_template_plugin.mdwn
1 [[tag wishlist]]
2
3 # Context
4
5 I may have missed a simple way to achieve what I need without
6 modifying ikiwiki, so here is the context.
7
8 I have a first-level directory (called `bricks`) containing a bunch of
9 wiki pages :
10
11     /bricks
12      |
13      |- bla.mdwn
14      |
15      |- bli.mdwn
16      |
17      `- ...
18
19 I have two groups of tags called `direction` and `usage`, stored in
20 two sub-directories of `$tagbase` :
21
22     /tag
23      |
24      |- direction
25      |    |- d1.mdwn
26      |    |- d2.mdwn
27      |    |- ...
28      |
29      |- usage
30      |    |- u1.mdwn
31      |    |- u2.mdwn
32      |    |- ...
33
34 Any page in `/brick` can be tagged with one or more tags from any of
35 these tags-groups.
36
37 I need to present different views for these wiki pages, so a `/view`
38 tree is dedicated to this mission :
39
40     /view
41      |
42      |- dev
43      |   |- d1.mdwn
44      |   |- d2.mdwn
45      |   |-...
46      |
47      |- howto
48          |- u1.mdwn
49          |- u2.mdwn
50          |- ...
51
52 ... where e.g. `/view/dev/d1` lists a subset (depending on other tags)
53 of the pages tagged d1.
54
55 My current plan is :
56
57 - thanks to the pagetemplate plugin, `/view/dev/*` and `/view/howto/*` would be assigned two custom templates, containing 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
59
60 # My issue
61
62 Such map directives would look something like the following (more
63 complicated, actually, but let's focus on my current issue) :
64
65         \[[!map pages="bricks/* and link(tag/usage/<TMPL_VAR BASENAME>)"]]
66
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.
72
73 Any idea ?
74
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.
78
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.
85
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 : there may be quite
88 a few, that's why I intend to use the pagetemplate plugin in the first
89 place to assign them a common template.)
90
91 More or less OT: I've not checked the compatibility of pagetemplate
92 and template plugins yet; can a template (`*.tmpl`), assigned by
93 pagetemplate, itself call a template (`*.mdwn`) managed by the
94 template plugin ? The hooks call order tends to make me think it is
95 not possible, which anyway would ruin my current plan.
96