]> sipb.mit.edu Git - ikiwiki.git/blob - doc/bugs/misctemplate_does_not_respect_the_current_page___40__if_any__41__.mdwn
(no commit message)
[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 ### A second example
22
23 * create "/bar/sidebar.mdwn" with "world"
24 * run ikiwiki
25 * with the web browser, go to the page "bar"
26 * notice the sidebar displays "world"
27 * click "edit"
28 * -> Problem: the sidebar now shows the foo link (it is the root sidebar!)
29 * -> Was expecte : the sidebar displays "world"
30
31 ### A last example
32
33 * with the web browser edit the page "bar"
34 * type <code>[<span></span>[!sidebar content="goodby"]]</code>
35 * click preview
36 * -> Problem: the sidebar still displays the foo link
37 * -> Was expected: the sidebar display "goodby"
38
39 ## Some superficial hacking
40
41 With the following workaround hacks, I manage to solve the 3 examples shown above:
42
43 1- edit IkiWiki/Plugin/editpage.pm and call showform with additional page and destpage parameters:
44 <pre>showform($form, \@buttons, $session, $q, forcebaseurl => $baseurl, page => $page, destpage => $page);</pre>
45
46 2- edit /usr/share/perl5/IkiWiki.pm and modify the misctemplate function to use the given page and destpage:
47 <pre>my %params=@_;
48 shift->(page => $params{page}, destpage => $params{destpage}, template => $template);</pre>
49
50 I do not guarantee (I do not even expect) that it is the proper way to solve this bug but it may help developers to find and solve the real problem.