1 [[!template id=gitbranch branch=anarcat/page-template-variable author="[[anarcat]]"]]
3 I do not understand why, but it seems like base templates included in the theme do not have access to the current page path. All sorts of plugins give all sorts of information about the page including its title, modification time, related pages (trail and parentlinks), tags, fields and so on... But *nothing* on just that: the page path.
5 It's a one-line patch to fix:
7 modified IkiWiki/Render.pm
8 @@ -123,6 +123,7 @@ sub genpage ($$) {
13 title => $page eq 'index'
15 : pagetitle(basename($page)),
18 The patch is available in my git repo, and also directly visible here:
20 https://gitlab.com/anarcat/ikiwiki/-/commit/9b471a6adcdf47e98dbe3a3aae68f3da4ab63fbb
22 I use this to include the page name in a tracking URL for (privacy-friendly) web analytics, thanks to Goatcounter. But it seems like a useful thing in general: for example, I remember a friend struggling to figure out how to theme the frontpage of his wiki differently, and he spent a long trying to figure out this very problem. I have myself spent about an hour scouring the source code before deciding the variable just did not exist.
24 The friend ended up using this construction instead:
26 <TMPL_UNLESS PARENTLINKS>
27 <link rel="stylesheet" href="css/style-frontpage.css" />
30 ... which might actually be more elegant, but way less flexible: what if you want to theme another page that way? In other words, the above only works for the frontpage, but maybe you want `/sales` to be themed differently than `/sandbox`...
32 In general, I think this is a minor change that can have a huge impact on the themability of ikiwiki, if we care about that at all. ;)
36 PS: I think it would be great if we had a way to figure out which variables are available in a template... I couldn't find out how to do that in HTML::Template, and wonder if we could have some way to do that, to ease such diagnostics in the future...
42 you're not alone: I think this is very similar to [[forum/how_to_put_a_permalink_on_each_post]].
44 > PS: I think it would be great if we had a way to figure out which variables are available in a template
46 I agree! Perhaps a subroutine that enumerated them all and a plugin to expose it or something.
47 I definitely wold find that useful too. *— [[Jon]], 2020-07-21*