[dokuwiki] Re: Template Plugin proposal...

  • From: Chris Smith <chris@xxxxxxxxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Thu, 31 Aug 2006 16:51:43 +0100

Terence J. Grant wrote:

I have looked at the plugin and read the thread. ;)

Ok, thanks :-)

My earlier point is that you don't need a code.php, use action.php which
will save you one line in your template and if you use a decide to a
event handler it'll save you the function_exists as well.
[...]
But as I keep trying to point out, Dokuwiki already has the mechanisms
to extend template functions.  They just need to be used. e.g. to add
button types and new action links, an event handled similarly to
template actions and TPL_ACT_UNKNOWN would do the trick.

Ok, I believe I understand now where you've been coming from. I didn't realize the tpl functions already had "action plugin aware" code in them in the current dev. (Again I only work with stable.)
Every part of DokuWiki (without any changes to those parts) is action plugin aware, that is one advantages of the system. There are three global elements:
- $EVENT_HANDLER
- event classes
- trigger_event function


All of which are included, instantiated and/or initialised whenever doku.php is run.

Grab a recent snapshot and take a look at action plugins before the next release to see where/how you can use them to do what you are thinking of. Just as a for instance, the blog plugin can make use of action plugins to implement itself without requiring any modification to the current template.

I think its still unlikely the template functions would be moved into a plugin. There isn't really the need. Action plugins work by triggering events either wrapped around dokuwiki activities or that signal some state in dokuwiki. For the first type the plugin can replace the dokuwiki activity or filter its input and/or output. If the dokuwiki activity itself was in a plugin that couldn't be guaranteed or would require a second event to achieve it.

e.g. consider two events, one wrapped around tpl_btn and the other fired within the function if the btn name isn't recognised.

With the first you can replace particular buttons or cause them not to be rendered.
With the second you can add capability to handle new buttons


If the dokuwiki functions were also in a plugin, you could no longer guarantee replacement as you wouldn't know if the dokuwiki template plugin had handled the event before your plugin or not.

Cheers,

Chris


-- DokuWiki mailing list - more info at http://wiki.splitbrain.org/wiki:mailinglist

Other related posts: