[dokuwiki] Re: Getting (admin) plugins straight

  • From: Andreas Gohr <andi@xxxxxxxxxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Thu, 15 Sep 2005 10:45:41 +0200

> > > Related to your plugin specific js/css point.  I think there needs
> > > to be a way for a plugin to tell dokuwiki that it wants to put
> > > code into other parts of the page.
> >
> > Yes that could solve some of the problems. That would mean my admin
> > plugin should use a non-standard named scriptfile and add it itself
> > to the head section of the page?
> 
> Hows about a pair of functions,
> 
> (1) function to allow plugin handle functions to interact with other
> places on the current page
> prototype: void register_pagecontent($location, $content)
> 
> (2) function to allow producers of page output to retrieve any extra
> output suitable to their location.
> prototype: array retrieve_pagecontent($location)

Extending this a little bit would finally bring us the admin plugins :

prototype: void register_hook($hook,$action)

plugin: run_action($hook,$action,&$data)

$data could be an array which holds different objects depending on the
kind of $hook. This could be a way to return XHTML to insert into the
page, or the text to save for an onSave hook.

> Functions that call retrieve_pagecontent should check each array
> element of the returned array
> - if its a string, simply output that string.
> - if its an array, treat the first element as a callback function and
> the second element as the data for that function and call the callback
> function with that data and the location name.

This is a very good idea as well :-) I like the idea of a
callback function.

I'll answer the syntax plugin questions in another mail.

Andi

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

Other related posts: