====== columns plugin ====== ---- plugin ---- description: Arrange information in multiple columns author : Michael Arlt email : michael.arlt@sk-schwanstetten.de type : syntax lastupdate : 2007-10-22 compatible : 2007-11-06 depends : conflicts : similar : tags : columns ---- ===== Description ===== You can arrange your information in multiple columns. Column breaks must be inserted manual. I use a table with one %%
information in column 1
~~NEWCOL~~
information in column 2
information in column 1 (50% width)
~~NEWCOL~~
information in column 2
~~NEWCOL~~
information in column 3
==== Columns2 Branch ====
The syntax is mostly identical to the original version, except that the new column keyword has to be specified within angle brackets:
information in column 1 (50% width)
information in column 2
information in column 3
===== Localisation =====
The keywords can be customized - see Dokuwiki: administration -> configuration.
^Language ^Start ^End ^Next Column ^
|English |
$lang['kwcolumns']
$lang['kwnewcol']
===== Download / Installation =====
Install the [[http://it-arlt.de/plugins/columns.zip|current release]] with the plugin manager. Have a look at the DokuWiki plugin configuration.
^ 2008-08-23 | [[http://home.tiscali.nl/~panone/dokuwiki/columns-2008-08-23.zip|Download]] |
===== Source Code =====
==== syntax.php ====
* @version 2007-10-22
*/
if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../../').'/');
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
require_once(DOKU_PLUGIN.'syntax.php');
function td($tdwidth,$css)
{
if ($tdwidth == "-")
{
return '';
}
else
{
return ' ';
}
}
/**
* All DokuWiki plugins to extend the parser/rendering mechanism
* need to inherit from this class
*/
class syntax_plugin_columns extends DokuWiki_Syntax_Plugin {
/**
* function constructor
*/
function syntax_plugin_columns(){
// enable direct access to language strings
$this->setupLocale();
}
/**
* return some info
*/
function getInfo(){
return array(
'author' => 'Michael Arlt',
'email' => 'michael.arlt@sk-schwanstetten.de',
'date' => '2007-10-22',
'name' => 'columns Plugin',
'desc' => 'Arrange information in multiple columns',
'url' => 'http://www.dokuwiki.org/plugin:columns',
);
}
/**
* What kind of syntax are we?
*/
function getType(){
return 'formatting';
}
function getPType(){
return 'normal';
}
/**
* What modes are allowed within our mode?
*/
function getAllowedTypes() {
return array('substition','protected','disabled','formatting');
}
/**
* Where to sort in?
*/
function getSort(){
return 1;
}
function connectTo($mode) {
$kwcolumns=$this->getConf('kwcolumns');
if ($kwcolumns=="") { $kwcolumns=$this->lang["kwcolumns"]; };
$this->Lexer->addSpecialPattern('<'.$kwcolumns.'.*?>.*?'.$kwcolumns.'>',$mode,'plugin_columns');
}
/**
* Handle the match
*/
function handle($match, $state, $pos, &$handler)
{
$kwnewcol=$this->getConf('kwnewcol');
if ($kwnewcol=="") { $kwnewcol=$this->lang["kwnewcol"]; };
$kwcolumns=$this->getConf('kwcolumns');
if ($kwcolumns=="") { $kwcolumns=$this->lang["kwcolumns"]; };
$length=strlen($this->lang["kwcolumns"])+2;
$end=strpos($match,">");
if($end > $length)
{
$width=preg_split('/ /',substr($match,$length,$end-$length));
}
#$lines="$kwcolumns:$kwnewcol:".substr($match,$length,$end-$length).":";
$css1=$this->getConf('css1');
$css2=$this->getConf('css2');
$css3=$this->getConf('css3');
$lines.='';
$column=0;
foreach (preg_split('/'.$kwnewcol.'/',substr($match,$end+1,-$length-1)) as $col)
{
if ($column==1) # first column
{
$lines.=td($width[$column],$css1);
$lines.= p_render('xhtml',p_get_instructions($oldcol),$info);
}
else
{
if ($column>1) # all other columns
{
$lines.=td($width[$column],$css2);
$lines.= p_render('xhtml',p_get_instructions($oldcol),$info);
}
}
$column++;
$oldcol=$col;
}
$lines.=td($width[$column],$css3);
$lines.= p_render('xhtml',p_get_instructions($oldcol),$info); # last column
$lines.='
';
return $lines;
}
/**
* Create output
*/
function render($mode, &$renderer, $data) {
if($mode == 'xhtml'){
$renderer->doc .= $data;
return true;
}
return false;
}
}
//Setup VIM: ex: et ts=4 enc=utf-8 :
===== Change History =====
==== Columns2 Branch ====
=== 2008-08-23 ===
* Fixed issue with the backlinks
* Columns styling is moved from configuration to ''style.css'' file
* Slightly different syntax: the new column keyword is wrapped in angle brackets (i.e. '' ... ... '')
==== 2007-10-22 ====
* First public release
* All desired features of the author are implemented
===== Thanks to ... =====
Andreas Gohr for Dokuwiki and now: S5!
===== License =====
This product is released under the [[http://www.gnu.org/licenses/gpl.html|GPL 2]]
===== Discussion =====
It works if I put NEWCOL rather than ~~NEWCOL~~ (I got ~~ appearing as text). The default language is pt-br.
// Please give me all information from both (the correct and incorrect) variants: What did you put in the configuration dialog? What do you put in the text? Please type the complete line with "$conf['plugin']['columns']['kwnewcol'] = ..." from your conf/local.php; //
In the text
information in column 1 (50% width)
NEWCOL
information in column 2 (15% width)
NEWCOL
information in column 3
In the configuration settings, I am going with the default (that is left blank). Check it at [[http://complex.if.uff.br/playground/playground|Playground]].
----
The same here - NEWCOL works better - ~~ are not displayed. Language is: pl. The settings are default.
//There is a small bug in .../columns/lang/en/lang.php - change line 10 from 'NEWCOL' to '~~NEWCOL~~' \\
Please tell me if the problem is fixed then. You can change it in the preferences too. If you enter ~~NEWCOL~~ it should work, too. \\
After this you must adjust your pages to the new pattern.//
> backlinks simply do not work with those links that occure inside a column. The metadata is not updated, the references aren't detected during the rendering, I can't find the way to deal with the problem, did anyone experience this? I am running the latest version of dokuwiki.
>Found a bug: when putting links to non-existing pages in one of the columns, the link is red ... no problem. But when you now click on it + create the page + go back to the page with the columns ... the link remains red. It only turns into the color of a valid pages //after// editing the page with the columns. I've just tested this on the playground-link provided in the first discussion comment in this page and it's the same there. In other words, not just because of my installation. Is it possible to give this some attention ... I plan on using this plugin heavily.
//I don't have any idea to fix this. This maybe a problem because i do not understand all of dokuwiki which i use. Any help is welcome. Michael//
>> this is just a caching issue and has nothing to do with the column plugin. Of course, the cache of the column page is not changed if a different (the target) page is edited or created
>>> You'll notice that links on wiki pages are "updated" once a new page was created. To omit that in the column plugin you could use the following in your handler function: $renderer->info['cache'] = false; --- //[[chi@chimeric.de|Michael Klier]] 2008/03/13 11:58//
>>>> Michael, I tried to solve this caching-issue using the way described by you above. Sadly it doesn't work. I tried to add the line in several different ways at several places in the code (although I assume it should be added to the method: function render($mode, &$renderer, $data) //before// the existing code), but nothing works. Can you maybe explain it a bit more or take a look at the code yourself? --- //[[mischa@the-evil.pointclark.net|Mischa The Evil]] 2008/04/16 23:30//
>>>>> Same problem here. In addition, ~~NOCACHE~~ at top of the page doesn't help either.[[stinkywinky@gmx.net|StinkyWinky]] 2008/05/20 14:26
>>>>>> Please publish your code here (or on your own site), that makes it easier and quicker to review your code without having to go to the trouble of installing the plugin. --- //[[chris@jalakai.co.uk|Christopher Smith]] 2008/05/21 11:15//
>>>>>>> [[#source_code|Here]] is the code ... If possible leave a hint using email... this will improve response time... //[[michael.arlt@sk-schwanstetten.de|Michael Arlt]] 2008/06/10 23:39//
>>>>>>>> I would really like to use this plugin more but the cache issue and it having problems outputting properly formatted xhtml is worrisome - [[vtingey@msl.ubc.ca|Vince]] 2008/08/21
* The columns plugin is working unstable with [[plugin:indexmenu]]. Apache error_log message is shown as following.
[client 220.130.131.238] PHP Fatal error: Allowed memory size of 16777216 bytes exhausted (tried to allocate 35 bytes) in /var/www/html/dev/inc/parser/parser.php on line 98, referer: http://www.everplast.net/dev/everplast/reinforcedhose/video?do=edit&rev=
After tracing the source code, I guess the error could be from that parser cannot found end tag. Does anyone have workaround solution or patch code? --- //[[tryweb@ichiayi.com|Jonathan Tsai]] 2008/07/11 09:26//
>This is not an error of DokuWiki or the Columns plugin. It is an error caused by the PHP-configuration. Your PHP-setup is limited to use not more then 16MB of memory. This error shows you that the limit has been reached.
>See the [[http://nl3.php.net/manual/en/ini.core.php#ini.memory-limit|PHP manual]] for more info about the related configuration-directive (//''memory_limit''//).
> --- //[[mischa_the_evil@hotmail.com|Mischa The Evil]] 2008/07/12 05:21//