[pmwiki-users] Three column text
Steve Glover
steve at fell-services.net
Thu Jan 31 07:36:00 CST 2008
Hi,
Recently someone was looking for a way of splitting a long table into
columns.
Ben Wilson's column recipe does this for two columns - nesting tables
aren't a problem when you put double-pipe markup tables inside the
pmwiki markup sort.
The recipe also lends itself to stretching:
Markup('columns', '_begin',
'/(.*?)\(:col1:\)(.*?)\(:col2:\)(.*)$/se',
"stripslashes(Columnize('$1', '$2','$3'))");
function Columnize($one, $two, $three) {
$bits = preg_split("/\(:colstart:\)/", $one);
list($pre, $one) = (count($bits) > 1) ? $bits : array('', $bits[0]);
$bits = preg_split("/\(:colend:\)/", $three);
list($three, $post) = (count($bits) > 1) ? $bits : array($bits[0],'');
return<<<RETURN
$pre
(:table class=columns border=0 cellspacing=0 cellpadding=6:)
(:cellnr valign=top width=33%:)
|| class="zebra" border=1 cellspacing=0 cellpadding=4
||!Member Organisation ||!IdPs||!SPs||
$one
(:cell valign=top width=33%:)
|| class="zebra" border=1 cellspacing=0 cellpadding=4
||!Member Organisation ||!IdPs||!SPs||
$two
(:cell valign=top width=33%:)
|| class="zebra" border=1 cellspacing=0 cellpadding=4
||!Member Organisation ||!IdPs||!SPs||
$three
(:tableend:)
$post
RETURN;
}
Okay, there's stuff I've done there that's Bad and Wrong: the table
headers should be in page markup, not in the recipe, for one. And for
another, rather than doing a "cargo cult" copy of Ben's code I should be
counting the lines in the original content between colstart and colend,
and splitting them at n/3 and 2n/3.
But in case it's of use to anyone, there you go....
Steve
--
Steve Glover at email: steve at fell-services.net
SDSS, EDINA, University of Edinburgh, tel: +44 (0)131-650 2908
Causewayside House, 160 Causewayside, fax: +44 (0)131-650 3308
Edinburgh EH9 1PR mobile: +44 (0) 7961 446 902
More information about the pmwiki-users
mailing list