web commit by intrigeri: created todo, proposed to implement it - need hint to choose...
[ikiwiki] / doc / todo / Allow_TITLE_to_include_part_of_the_path_in_addition_to_the_basename.mdwn
1 I need to display part of my pages' path in the `<title>` meta HTML
2 header instead of their basename ; e.g. for /abs/path/to/basename, I'd
3 like to set it to path/to/basename.
4
5 Of course, one might consider it's my own problem, as I could
6 workaround this in my templates, and replace, in the `<title>` meta
7 HTML header, `<TMPL_VAR TITLE>` with a `TMPL_LOOP` on `PARENTLINKS`,
8 but...
9
10 - it's ugly (call it a semantic hijacking if you want) ; a side-effect
11   of this ugliness is :
12 - it defeats any further plugin's (e.g. [[plugins/meta]])
13   attempt to override the default title with a nicer one ;
14 - all parents appear : there is no way to specify how deep to go up in
15   the parents tree.
16
17 So I really want to avoid this ugly workaround.
18
19 Looking at `Render.pm`, the second solution I thought of was :
20
21 - add a `parents_in_page_title` configuration option (default=0, i.e.
22   the current behaviour) ;
23 - modify `Render.pm` to insert as much parents as possible (up to
24   `N=parents_in_page_title`), separated by '/', in the `title`
25   template parameter, before the actual page basename ; I personally
26   would use N=2.
27
28 The only problems I can see with this approach are :
29
30 - it requires modification of the core, which may not be desirable
31 - the resulting title would be unconditionally overridden by the meta
32   plugin, and I can think of no clean solution to make this
33   configurable without hacking [[plugins/meta]], which I'd rather not
34   to ; I don't care, but once you add a ad-hoc feature to the core,
35   you can be sure someone will want a more generic version in less than
36   three months ;)
37
38 I'm not too convinced writing a plugin for such a small feature isn't
39 overdoing it, so I'm tempted to implement this solution in the
40 simplest way : the generated title would be the default and could be
41 overridden later by plugins.
42
43 Joey, what do you think ?
44
45 (Before starting to write any single line of code, I need to know how
46 much you are on the "if you can do it as a plugin, don't ever modify
47 the core" side... :)
48
49 In case you're on the hardcore side, I would probably write
50 a dedicated plugin, called `genealogictitle` or whatever, and :
51
52 - use the pagetemplate hook to modify the `title` template parameter,
53   and maybe set `title_overridden`, as does the meta plugin
54 - add a `genealogictitle_depth` configuration option to tell how many
55   parents to display
56 - maybe add a `genealogictitle_overrides_meta` or whatever to decide
57   whether a title overridden by [[plugins/meta]] should be overridden
58   by genealogictitle ; but anyway, I've not found, in the plugins
59   documentation, any hint about the order in which the plugins are
60   called for a given hook, so the "choose the strongest between meta
61   and genealogictitle" thing might just be more complicated... (no,
62   I did not Read The Nice Source, yet).
63
64 -- intrigeri