I really like the new approach to having only one main template "page.tmpl". For instance, it improves previews during edits.
But it causes some nasty bugs for plugins that use the pagetemplate hook. It is especially visible with the [[plugins/sidebar]] plugin.
## Some examples
### A first example
* activate sidebars globally and cgi
* create "/sidebar.mdwn" with "[[foo]]" inside
* create "/foo.mdwn" with "hello!" inside
* create "/bar.mdwn"
* run ikiwiki
* with the web browser, go to the page "bar"
* notice the sidebar, click on "foo"
* notice the page "foo" is now displayed (hello!)
* return the the page "bar" and click "edit"
* notice the sidebar is still here, click on the "foo"
* -> Problem: 404, the browser goes to "/bar/foo"
* -> Was expected: the browser goes to "/foo"
> You must have a locally modified `page.tmpl` that omits the "TMPL_IF DYNAMIC"
> that adds a `[[!sidebar content="goodby"]]
* click preview
* -> Problem: the sidebar still displays the foo link
* -> Was expected: the sidebar display "goodby"
> In the specific case of previewing, it is indeed a bug that the
> right sidebar is not displayed. And replacing the regular sidebar
> with the one from the previewed page is probably the best we can do..
> displaying 2 sidebars would be confusing, and the `page.tmpl` can
> put the sidebar anywhere so we can't just display the preview sidebar
> next to the rest of the page preview. --[[Joey]]
>> The behavior is fine for me. However, some nitpicking (fell free to ingore) :
>>
>> * If the sidebar is replaced (making the previewing in-place), for consitency, should not the previewed content also shown in-place ? i.e. above the form part
>> * there is no way to come back (without saving or canceling) to the root context (e.g. displaying the root sidebar) i.e. some sort of unpreviewing.
>>
>> -- [[JeanPrivat]]
## Some superficial hacking
With the following workaround hacks, I manage to solve the 3 examples shown above:
1- edit IkiWiki/Plugin/editpage.pm and call showform with additional page and destpage parameters:
showform($form, \@buttons, $session, $q, forcebaseurl => $baseurl, page => $page, destpage => $page);2- edit /usr/share/perl5/IkiWiki.pm and modify the misctemplate function to use the given page and destpage:
my %params=@_; shift->(page => $params{page}, destpage => $params{destpage}, template => $template);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. > Oh, it's pretty reasonable. I don't think it breaks anything. :) > I modified it a bit, and explicitly made it *not* "fix" the second example. > --[[Joey]] >> I removed the done tag (I suspect it is the way to reopen bugs) -- [[JeanPrivat]]