DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:oddeven

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
plugin:oddeven [2017-05-13 23:09] – [Syntax] rrandallplugin:oddeven [2023-04-04 20:42] (current) Aleksandr
Line 1: Line 1:
 ====== OddEven Plugin ====== ====== OddEven Plugin ======
 ---- plugin ---- ---- plugin ----
-description: Paints table rows background to alternating colour stripes.+description: Paints table rows background to alternating colour stripes
 author     : Vladimir Uryvaev author     : Vladimir Uryvaev
 email      : az@vovanium.ru email      : az@vovanium.ru
 type       : action type       : action
 lastupdate : 2009-03-24 lastupdate : 2009-03-24
-compatible : 2016-06-26a "Elenor of Tsort"+compatible : Elenor of Tsort, !Igor
 depends    :  depends    : 
 conflicts  conflicts 
Line 15: Line 15:
 ---- ----
  
-===== Download and Installation =====+===== DownloadInstallation, License =====
  
-Download and manually install the plugin using the [[plugin:plugin|Plugin Manager]] using the following URL. Refer to [[:Plugins]] on how to install plugins manually.+Search and install the plugin using the [[extension|Extension Manager]]. Refer to [[:Plugins]] on how to install plugins manually.
  
   * http://vovanium.ru/_media/set/oddeven.tgz   * http://vovanium.ru/_media/set/oddeven.tgz
Line 25: Line 25:
 ===== Syntax ===== ===== 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.+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).
  
-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 ===== ===== Plugin internals =====
 +
 You may use it as tutorial on how to create output modification plugins. You may use it as tutorial on how to create output modification plugins.
  
Line 35: Line 37:
   - //style.css// -- stylesheet.   - //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.+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(([[user>Chris75|Chris75]])) fixed the code, so it works again (in "[[changes#release_2022-07-31a_igor|Igor]]"). Download, unpack the plugin directory ''/oddeven'' to your harddrive, update the code in ''action.php'' like so:  
 + 
 +<code php> 
 +<?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] 
 + ); 
 +
 +
 + 
 +?> 
 +</code> 
 + 
 +And replace all code in style.css by the following two lines: 
 + 
 +<code css> 
 +table tr:nth-child(odd) { background-color: #f0ede6; } 
 +div.wrap_skip_css tr { background-color: white; } 
 +</code> 
 + 
 +... to make it compatible with modern javascript filtering and sorting ([[sortablejs]], [[datatable]], [[struct]]). Adjust the color to your liking (optional). Now, archive the directory ''/oddeven'' back to a zip file. Finally, install the plugin through the plugin manager from your harddrive (manual installation) and select the ''oddeven.zip'' file. 
 + 
 +Now, you can even exclude individual tables from the zebra coloring using the [[wrap|wrap plugin]] with following syntax on your wiki page: 
 + 
 +<code> 
 +<WRAP skip_css> 
 +... your table here 
 +</WRAP> 
 +<WRAP clear/> 
 +</code> 
 +    
 +**Note:** If using ''<sortable>'' and ''<WRAP skip_css>'' on the same table make sure, ''<sortable>'' is the outer wrap and ''<WRAP skip_css>'' is the inner wrap. It then works in harmony.
  
 +--- [[user>Chris75|Chris75]] //2023-04-04//
  
plugin/oddeven.1494709776.txt.gz · Last modified: 2017-05-13 23:09 by rrandall

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki