]> sipb.mit.edu Git - ikiwiki.git/blob - doc/bugs/misctemplate_does_not_respect_the_current_page___40__if_any__41__.mdwn
2ef5cdba3d56e0cd85271108518bfda2dc148a2b
[ikiwiki.git] / doc / bugs / misctemplate_does_not_respect_the_current_page___40__if_any__41__.mdwn
1 I really like the new approach to having only one main template "page.tmpl". For instance, it improves previews during edits.
2 But it causes some nasty bugs for plugins that use the pagetemplate hook. It is especially visible with the [[plugins/sidebar]] plugin.
3
4 ## Some examples
5
6 ### A first example
7
8 * activate sidebars globally and cgi
9 * create "/sidebar.mdwn" with "[<span></span>[foo]]" inside
10 * create "/foo.mdwn" with "hello!" inside
11 * create "/bar.mdwn"
12 * run ikiwiki
13 * with the web browser, go to the page "bar"
14 * notice the sidebar, click on "foo"
15 * notice the page "foo" is now displayed (hello!)
16 * return the the page "bar" and click "edit"
17 * notice the sidebar is still here, click on the "foo"
18 * -> Problem: 404, the browser goes to "/bar/foo" 
19 * -> Was expected: the browser goes to "/foo"
20
21 > You must have a locally modified `page.tmpl` that omits the "TMPL_IF DYNAMIC"
22 > that adds a `<base>` tag. That is needed to make all links displayed by
23 > cgis work reliably. Not just in this page editing case.
24 > The [[version_3.20100515]] announcment mentions that you need to
25 > update old `page.tmpl` files to include that on upgrade. --[[Joey]]
26
27 ### A second example
28
29 * create "/bar/sidebar.mdwn" with "world"
30 * run ikiwiki
31 * with the web browser, go to the page "bar"
32 * notice the sidebar displays "world"
33 * click "edit"
34 * -> Problem: the sidebar now shows the foo link (it is the root sidebar!)
35 * -> Was expecte : the sidebar displays "world"
36
37 > One could argue that the behavior here is right, or wrong. 
38 > Is a page edit page really the same as the page being edited?
39 > The next case is more clear.. --[[Joey]]
40
41 ### A last example
42
43 * with the web browser edit the page "bar"
44 * type <code>[<span></span>[!sidebar content="goodby"]]</code>
45 * click preview
46 * -> Problem: the sidebar still displays the foo link
47 * -> Was expected: the sidebar display "goodby"
48
49 > I think this is worth fixing. --[[Joey]]
50
51 ## Some superficial hacking
52
53 With the following workaround hacks, I manage to solve the 3 examples shown above:
54
55 1- edit IkiWiki/Plugin/editpage.pm and call showform with additional page and destpage parameters:
56 <pre>showform($form, \@buttons, $session, $q, forcebaseurl => $baseurl, page => $page, destpage => $page);</pre>
57
58 2- edit /usr/share/perl5/IkiWiki.pm and modify the misctemplate function to use the given page and destpage:
59 <pre>my %params=@_;
60 shift->(page => $params{page}, destpage => $params{destpage}, template => $template);</pre>
61
62 I do not guarantee (I do not even expect) that it is the proper way to solve
63 this bug but it may help developers to find and solve the real problem. 
64
65 > Oh, it's pretty reasonable. I don't think it breaks anything. :)
66 > [[done]]
67 > --[[Joey]]