]> sipb.mit.edu Git - ikiwiki.git/blob - doc/bugs/misctemplate_does_not_respect_the_current_page___40__if_any__41__.mdwn
Merge commit '1609da8f00e29c580e92fd1d3c2b093cbc41d20e' into sipb
[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 > I think it's a misconception to think that the page editing page is the same
38 > as the page it's editing. If you were deleting that page, would you expect
39 > the "are you sure" confirmation page to display the page's sidebar?
40 > --[[Joey]]
41
42 ### A last example
43
44 * with the web browser edit the page "bar"
45 * type <code>[<span></span>[!sidebar content="goodby"]]</code>
46 * click preview
47 * -> Problem: the sidebar still displays the foo link
48 * -> Was expected: the sidebar display "goodby"
49
50 > In the specific case of previewing, it is indeed a bug that the
51 > right sidebar is not displayed. And replacing the regular sidebar 
52 > with the one from the previewed page is probably the best we can do..
53 > displaying 2 sidebars would be confusing, and the `page.tmpl` can
54 > put the sidebar anywhere so we can't just display the preview sidebar
55 > next to the rest of the page preview. --[[Joey]]
56
57 ## Some superficial hacking
58
59 With the following workaround hacks, I manage to solve the 3 examples shown above:
60
61 1- edit IkiWiki/Plugin/editpage.pm and call showform with additional page and destpage parameters:
62 <pre>showform($form, \@buttons, $session, $q, forcebaseurl => $baseurl, page => $page, destpage => $page);</pre>
63
64 2- edit /usr/share/perl5/IkiWiki.pm and modify the misctemplate function to use the given page and destpage:
65 <pre>my %params=@_;
66 shift->(page => $params{page}, destpage => $params{destpage}, template => $template);</pre>
67
68 I do not guarantee (I do not even expect) that it is the proper way to solve
69 this bug but it may help developers to find and solve the real problem. 
70
71 > Oh, it's pretty reasonable. I don't think it breaks anything. :)
72 > I modified it a bit, and explicitly made it *not* "fix" the second example.
73 > [[done]]
74 > --[[Joey]]