Render DW syntax

Use Case:
You want to do something on output but want to keep a part of it rendered according DokuWiki syntax.

Think of a usual DokuWiki text where you want to wrap around a plugin to add further information on top/bottom or modify otherwise. You dont want to re-invent the dokuwiki syntax handling considering all the possible options but you want to render it as such. Lets assume you want to built a div around, with own styling and content including a simple DokuWiki text including syntax. You would develop a syntax plugin to extend Dokuwiki function accordingly. It may look like following syntax used inside DokuWiki Editor:

<your_plugin_opening|your parameters>
__**the raw dokuwiki syntax may be inserted or it is retrieved from a page/form**__ 
[[links]] {{pictures}} <color> and other plugin syntax.
<div class="my_plugin">
   <span class="my_plugin_headline"> your headline </span>
      HTML code of rendered DokuWiki syntax
         ouput created by use of p_render() function
   <span class="my_plugin_footer"> your footer </span>

Develop the plugin according your needs to define the output around the raw DokuWiki content.
DokuWiki raw syntax and content is to be send to the renderer to get the HTML output accordingly. Therefore we use the related DokuWiki functions p_render and p_get_instructions.

You may use the plugin php-code skeleton of our Plugin Dev tutorial and develop the next given php-syntax within

function render($mode, &$renderer, $params)


   Precondition: you have already separated your syntax [$yourParameter_array()] 
                 from DW raw content inside your syntax tags [$rawString]
    $yourParameter_array = array();
    $yourParameter_array = $params;  //or you directly take over $params by function call
 // create the html-output [$output] caused by your adds here [$output], like following example
 // let's assume you want to create it as a div-block and start with open tag and class for styling
    $output = '<div class="my_tables">'.NL;
 // your Headline has the ability to be given with DS syntax ?
 // => then it is to be rendered by DW
    $dw_rendered_headline = p_render('xhtml',p_get_instructions($yourParameter_array['headline']),$info);
 // now let DW render the raw content provided between your own syntax tags
 // Remember: this will be styled by DW settings
    $dw_rendered_output = p_render('xhtml',p_get_instructions($rawString),$info);
 // your Footer has the ability to be given with DS syntax ?
 // => then it is to be rendered by DW
    $dw_rendered_footer = p_render('xhtml',p_get_instructions($yourParameter_array['footer']),$info);
 // assamble the result together into $output
    $output .= '<span class="my_tables_headline"> $dw_rendered_headline </span>'.NL;
    $output .= $dw_rendered_output.NL;
    $output .= '<span class="my_tables_footline"> $dw_rendered_footer </span>'.NL;
    $output .= '</div>'.NL;
  // now the output is completed and can be inserted into to the DW output stream
    $renderer->doc .= $output;

The plugin header is to be extended by following:



The following will deliver the files raw content of current page without parsing and converting it. It may be used to wrap something around the complete page content.

global $ID;
$rawString = rawWiki($ID);


see DokuWiki core functions reference:

tips/tips_p_render.txt · Last modified: 2014/04/30 09:36 (external edit)

This Wiki is hosted and ruled by Policies of Frister Consultancy Services.
By using this wiki you accept these rules. -> Impressum