[dokuwiki] Re: Plugins, modes and, in particular, 'substition'

  • From: Michael Hamann <michael@xxxxxxxxxxxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Sun, 16 Oct 2011 21:36:16 +0200

Hi,

On Sun, Oct 16, 2011 at 5:55 PM, Chris G <cl@xxxxxxxx> wrote:
> I'm interested in getting some plugins to nest, such that I can set the
> parameters for one plugin (the include plugin in particular) with the
> result of another plugin (it's a plugin I have written myself, called xv).

I would suggest the following: If you don't mind being dependent on
internal changes in the include plugin, I would simply call the render
function of the include plugin, or rather the plugin function of the
renderer with the parameters you want. The handle function of the
include plugin is pretty small so it won't be a big problem to do the
processing of the parameters in your plugin. The only problem might
be, that the include plugin expects the section level as last
parameter, just look at what the action part of the include plugin
does. You could also call the helper functions the include plugin
provides, but then you don't get the full cache handling the include
plugin does.

If you want to do even more advanced stuff you could also simply
modify the instructions, i.e. when you find the instructions of your
plugin and then the include plugin afterwards, modify the instructions
of the include plugin. Just look at the include plugin in order to get
some ideas how you could modify the instructions.

Btw. concerning your other email: once you have the instructions of
the syntax you want to execute, you can simply strip the
document_start and document_end instructions, close the currently
opened section, call the nest() function of the renderer with the
instructions you want to execute and then open the section again
(that's what the include plugin needs the section level for). This is
a lot faster than generating a new renderer by calling p_render. When
you generate the instructions you want to execute in the
handle()-function, the render function should be as fast as with
"normal" instructions.

A "clean" solution without such "hacks" is unfortunately not really
possible as the DokuWiki parser doesn't support that afaik.

Michael
-- 
DokuWiki mailing list - more info at
http://www.dokuwiki.org/mailinglist

Other related posts: