This is an old revision of the document!
Table of Contents
OddEven Plugin
Compatible with DokuWiki
- 2024-02-06 "Kaos" unknown
- 2023-04-04 "Jack Jackrum" unknown
- 2022-07-31 "Igor" no
- 2020-07-29 "Hogfather" unknown
Download and Installation
Search and install the plugin using the Extension Manager. Refer to Plugins on how to install plugins manually.
You may visit original plugin page (in Russian) and see a demonstration: http://vovanium.ru/set/oddeven. Plugin is released as Public Domain, because of triviality.
Syntax
No syntax required. Once the plugin is installed, the background of ALL tables in your Dokuwiki will have alternating (odd) rows colored light grey.
However, you can modify the color of the rows OR change the alternation from odd to even by modifying the style.css file included in the download (see below).
Plugin internals
You may use it as tutorial on how to create output modification plugins.
Plugin consists of two files:
- action.php – the main code;
- style.css – stylesheet.
As plugin run, is registers RENDERER_CONTENT_POSTPROCESS action hook called 'oddeven'. When hook is called, it adds class 'roweven' to 'td' tags having class 'row0', 'row2' etc. and 'rowodd' for 'row1', 'row3' etc. using regexp replacement. Stylesheet defines class 'roweven' to have lightgray background color.
Discussion
This plugin was not functioning anymore. I fixed the code, so it works again (in Igor). Just update the code in action.php like so: (and change the color to your liking in style.css)
<?php /** * OddEven Plugin * @license Public Domain * @author Vladimir Uryvaev <az@vovanium.ru> */ // must be run within Dokuwiki if(!defined('DOKU_INC')) die(); if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); require_once(DOKU_PLUGIN.'action.php'); class action_plugin_oddeven extends DokuWiki_Action_Plugin { function getInfo() { return array( 'author' => 'Vladimir Uryvaev', 'email' => 'az@vovanium.ru', 'date' => '2009-03-24', 'name' => 'OddEven', 'desc' => 'Colorize table rows like zebra', 'url' => 'http://vovanium.ru/set/oddeven', ); } function register($controller) { $controller->register_hook( 'RENDERER_CONTENT_POSTPROCESS', 'AFTER', $this, 'oddeven', array()); } function oddeven($event, $param) { $event->data[1] = preg_replace ( '/<tr class="row([0-9]*[02468])/si', '<tr class="row\\1 roweven', $event->data[1] ); $event->data[1] = preg_replace ( '/<tr class="row([0-9]*[13579])/si', '<tr class="row\\1 rowodd', $event->data[1] ); } } ?>