[dokuwiki] Re: Specifying page template for new pages in URL
- From: Jason Grout <jason-doku@xxxxxxxxxxxxxxxx>
- To: dokuwiki@xxxxxxxxxxxxx
- Date: Fri, 23 Feb 2007 03:01:43 -0700
Chris Smith wrote:
Jason Grout wrote:
I looked on the events list page at:
http://wiki.splitbrain.org/wiki:events_list
Are you referring to the HTML_EDITFORM_INJECTION or
HTML_PAGE_FROMTEMPLATE events? It seems like the
HTML_PAGE_FROMTEMPLATE might be an interesting one to look at.
Let me make sure that I understand the event system. I can register a
callback function that will be called when the event is triggered.
From the documentation and the source in html_edit, it appears that
the only information I have to work with in the HTML_PAGE_FROMTEMPLATE
is the ID of the page being created. That's not enough for my
purposes (I can't necessarily tell what template I want just from the
namespace), though it's a start. Is there a way to access the URL
parameters from the event callback? I'm sorry if I seem to have a
fixation on the URL parameters, but it's the only way I can think of
passing the name of a desired template to the create/edit page.
Thanks,
Jason
Sure, $_GET['my_var'] !
Okay, it's done.
There's a newpagetemplate action plugin that will look for the
"newpagetemplate" parameter in $_REQUEST. If the parameter exists, then
the page is loaded as a template, with the substitutions currently
offered by the namespace templates. Note that this overrides the
namespace template.
I have a quick question about my implementation. In the following, a
BEFORE callback is an event handler registered with the BEFORE
advisement (sp?), and similarly for an AFTER callback. I implemented the
plugin as a BEFORE callback, then manually set the $event->result
variable and called $event->preventDefault(). Is that all right to do
in a BEFORE callback? The documentation seems to indicate that you
should only mess with $event->result in an AFTER callback. However, I'd
just as soon not go through the expense of loading the default namespace
template if I know I'm overriding it. I suppose I could make two
callbacks, one BEFORE and one AFTER, with the BEFORE callback checking
the $_REQUEST variable and preventing the default, while the AFTER
callback actually loads the page, but that seems wasteful as well.
I've also patched the addnewpage plugin to take advantage of the
newpagetemplate functionality. The new syntax is:
{{NEWPAGE>ns|:newpage:template}}
where the new page template follows the vertical bar. I posted the
patch up to the addnewpage plugin discussion area.
Thanks again for everyone's help!
Jason
--
DokuWiki mailing list - more info at
http://wiki.splitbrain.org/wiki:mailinglist
- Follow-Ups:
- [dokuwiki] Re: Specifying page template for new pages in URL
- From: Chris Smith
- References:
- [dokuwiki] Re: Specifying page template for new pages in URL
- From: Anthony . Caetano
- [dokuwiki] Re: Specifying page template for new pages in URL
- From: Andreas Gohr
- [dokuwiki] Re: Specifying page template for new pages in URL
- From: Jason Grout
- [dokuwiki] Re: Specifying page template for new pages in URL
- From: Chris Smith
Other related posts:
- » [dokuwiki] Specifying page template for new pages in URL
- » [dokuwiki] Re: Specifying page template for new pages in URL
- » [dokuwiki] Re: Specifying page template for new pages in URL
- » [dokuwiki] Re: Specifying page template for new pages in URL
- » [dokuwiki] Re: Specifying page template for new pages in URL
- » [dokuwiki] Re: Specifying page template for new pages in URL
- » [dokuwiki] Re: Specifying page template for new pages in URL
- » [dokuwiki] Re: Specifying page template for new pages in URL
- » [dokuwiki] Re: Specifying page template for new pages in URL
- » [dokuwiki] Re: Specifying page template for new pages in URL
Jason Grout wrote:
I looked on the events list page at: http://wiki.splitbrain.org/wiki:events_listAre you referring to the HTML_EDITFORM_INJECTION or HTML_PAGE_FROMTEMPLATE events? It seems like the HTML_PAGE_FROMTEMPLATE might be an interesting one to look at.Let me make sure that I understand the event system. I can register a callback function that will be called when the event is triggered. From the documentation and the source in html_edit, it appears that the only information I have to work with in the HTML_PAGE_FROMTEMPLATE is the ID of the page being created. That's not enough for my purposes (I can't necessarily tell what template I want just from the namespace), though it's a start. Is there a way to access the URL parameters from the event callback? I'm sorry if I seem to have a fixation on the URL parameters, but it's the only way I can think of passing the name of a desired template to the create/edit page.Thanks, Jason
Sure, $_GET['my_var'] !
- [dokuwiki] Re: Specifying page template for new pages in URL
- From: Chris Smith
- [dokuwiki] Re: Specifying page template for new pages in URL
- From: Anthony . Caetano
- [dokuwiki] Re: Specifying page template for new pages in URL
- From: Andreas Gohr
- [dokuwiki] Re: Specifying page template for new pages in URL
- From: Jason Grout
- [dokuwiki] Re: Specifying page template for new pages in URL
- From: Chris Smith