[dokuwiki] Re: Nested substitution plugins - are they possible?

  • From: Myron Turner <turnermm02@xxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Fri, 17 Dec 2010 10:52:31 -0600

On 12/17/2010 9:44 AM, Chris G wrote:
I want to nest the output of one plugin inside the values provided to another:-

The 'outer' plugin is the SQL plugin, the inner one is my own which
expands a link parameter, thus I want to write something like this:-

     <sql db="sqlite:////var/www/boat/data/meta/boat.db" wikitext="enable" 
special="plain"..>
     SELECT Summary from bePlaces where Name like '<xv>name</xv>'</sql>


The<xv>name</xv>  expands to a place name and is fed into the SELECT
being run by the SQL plugin.

Is this even possible and, if so, how does one do it?  I obviously need
to get Dokuwiki to run the<xv>  plugin expansion before the<sql>  one.

Any/all advice would be very welcome.


You appear to be using plugin:sql, which is a syntax plugin. If you look at the code in syntax.php, in the handle method, you will find the following case:
       DOKU_LEXER_UNMATCHED
It is here that the queries are collected (and subsquently passed on to the render method). Before allowing the queries to be passed along, replace your place holders with the values from the query string.

 case  DOKU_LEXER_UNMATCHED:
    $queries = explode(';', $match);
    /* add the following code */
    $name = $_GET['my_name'];
    $queries = str_replace('<xv>name</xv>', "<xv>$name</xv>",$queries);

This will replace the place-holder 'name' with the same value in each query in the array. This should work, and if you have multiple place-holders to replace you can do them one at a time or all at once using arrays (see the php documentation).




--
Myron Turner
http://mturner.org/
http://mturner.org/fckgLite
http://www.mturner.org/dwfck/doku.php
http://www.room535.org


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

Other related posts: