Dokuwiki - Render Plugin

Card Puncher Data Processing

About

The xhtml renderer.

If you want to add content without adding a tag in your page, you need to create your own render engine.

Prerequisites

You need to have basic knowledge of the dokuwiki parser

Variable

Plugin Name: myrender

Steps

  • Create a render plugin with the Wizard plugin
  • Example of a plugin info file (in lib/plugins/myrender/)
base   myrender
author Nicolas GERARD
email  gerardnico's mail @gmail.com
date   2015-04-02
name   Render Plugin of Gerardnico.com
desc   Render plugin that add generated content after the first section of the second level of headings
url    https://www.dokuwiki.org/plugin:nicorender

The name of your class must be renderer_plugin_“Name of my Render Plugin”, renderer_plugin_“Value of base in plugin info file” (ie renderer_plugin_myrender)

  • Add the canRender() method to the render class in order to list the plugin in the options for config%3Arenderer_xhtml setting in its Configuration Manager.
public function canRender($format) {
    return ($format=='xhtml');
}
  • Add the getFormat function
function getFormat() {
        return 'xhtml';
}

Dokuwiki Render Xhtml Configuration

Example

<?php

if(!defined('DOKU_INC')) die('meh.');


require_once DOKU_INC.'inc/parser/xhtml.php';

/**
 * DokuWiki Plugin nicorender (Renderer Component)
 *
 * The Nico XHTML Renderer
 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
 * @author  Nicolas GERARD <gerardnico at the gmail.com>
 *
 * This is a replacement render of the DokuWiki's main renderer
 * That format the content that's output the tpl_content function.
 */
class  renderer_plugin_nicorender extends Doku_Renderer_xhtml
{

    function getFormat() {
        return 'xhtml';
    }

    /*
     * Function that enable to list the plugin in the options for config:renderer_xhtml
     * http://www.dokuwiki.org/config:renderer_xhtml
     * setting in its Configuration Manager.
     */
    public function canRender($format)
    {
        return ($format == 'xhtml');
    }


    /**
     * Modify the render of an heading
     *
     * @param string $text the text to display
     * @param int $level header level
     * @param int $pos byte position in the original source
     */
    function header($text, $level, $pos)
    {
        // Add the level and position information
        $this->doc .= '<p>Header Level: ' . $level . ', Position ' . $pos. '</p>';

        // Call the parent function (ie xhtml.php:header)
        parent::header($text, $level, $pos);

    }


}

Documentation / Reference





Discover More
Card Puncher Data Processing
DokuWiki

is a standards compliant, simple to use Wiki, mainly aimed at creating documentation of any kind. It is targeted at developer teams, workgroups and small companies. It...
Card Puncher Data Processing
Dokuwiki - Renderer

The wikipage parsing process has two stages: generation of the instructions by the devel:parserHandler and next the generation of output via a renderer (with these instructions as input.)
Card Puncher Data Processing
Dokuwiki - Renderer Mode

Renderer Mode The special mode metadata does not output anything but collects metadata for the page. Use it to insert values into the metadata array. i stands for instructions. A page is...



Share this page:
Follow us:
Task Runner