On 12/17/2010 11:52 AM, Chris G wrote:
Write a separate syntax plugin that captures every case of your place-holders and give it a lower sort number than the sql plugin. The substitutions will be made before the sql gets its turn.On Fri, Dec 17, 2010 at 10:52:31AM -0600, Myron Turner wrote: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).Yes, I could do this, implement the substitution as a modification of the sql plugin. However I really want to be able to do similar substitutions elsewhere as well so it would be much nicer if I could implement the substitution as a separate plugin.
You would need only one plugin that captures every case and you could easily add to it as needed.
-- 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