Wiki source for OnegWRCol


Show raw source

===== Column Action =====
>>**See Also**
~- tbd
>>//NOT Included in any Wikka version yet//{{lastedit}}
==What==
~- A way to print text in columns via <div> tags.

==Use==
~- Start the column by calling the col action with an parameter, stop the col by calling col by it's own.
~~""{{col class="floatr"}}This is the same as putting the text in >> tags{{col}}""
~~""{{col left="DIV"}}{{col left="33"}}First column{{col}}{{col left="34"}}Middle column{{col}}{{col left="33"}}Last column{{col}}{{col}}""

==Parameters==
~""<table cellspacing="0" cellpadding="2" border="1"><thead>
<tr><th scope="col">name</th><th scope="col">type</th><th scope="col">required?</th><th scope="col">default</th><th scope="col">description</th></tr>
</thead><tbody>
<tr><td>id</td><td>string</td><td>optional</td><td>empty</td><td>Define the id of this column.</td></tr>
<tr><td>class</td><td>string</td><td>optional</td><td>empty</td><td>Define the class of this column.</td></tr>
<tr><td>left</td><td>(pos) integer</td><td>optional</td><td>empty</td><td>Width + left alignment</td></tr>
<tr><td>right</td><td>(pos) integer</td><td>optional</td><td>empty</td><td>Width + right alignment</td></tr>
</tbody>
</table>""

==Features==
~- If no param is send, a closing </div> is returned.
~- Left and right params can't be used in the same call, left has priority in this case.
~- Left and right dimensions are percentages when smaller then 100, px when bigger. (if you need to add a column with a width of 80px you'll need to alter this in the code)
~- If an empty param or wrong format is used, a clean <div> is retured, this would be a good idea to wrap this around your columns if you plan on using the full width of the page. (Looks nicer with the text above/below.)
~- **W A R N I N G**: by not closing tags,... is it realy easy to mix up you current css layout...

==Installation==
~- Save the code below as ##action/col.php##
~- Give it the same file permissions as the other php files in that directory.

==Code==
~%%(php)<?php
// Col - print <DIV> columns
// by OnegWR, may 2005, License GPL
$col_id=$col_class=$col_left=$col_right="";
if(is_array($vars) AND $vars <> array() ){
if(isset($vars['id'])){
$col_id = preg_replace("%[^A-Za-z0-9]%", "", $vars['id']);
if( $col_id <> '' ){ $col_id = " id=\"$col_id\""; }
}
if(isset($vars['class'])){
$col_class = preg_replace("%[^A-Za-z0-9]%", "", $vars['class']);
if( $col_class <> '' ){ $col_class = " class=\"$col_class\""; }
}
if(($col_id=='') AND ($col_class=='')){
if(isset($vars['left'])){
$col_left = preg_replace("%[^0-9]%", "", $vars['left']);
if( $col_left <> '' ){
$col_left>100 ? $col_left=" style=\"width: $col_left; float: left;\"" : $col_left=" style=\"width: $col_left%; float: left;\"";
}
}elseif(isset($vars['right'])){
$col_right = preg_replace("%[^0-9]%", "", $vars['right']);
if( $col_right <> '' ){
$col_right>100 ? $col_left=" style=\"width: $col_right; float: right;\"" : $col_right=" style=\"width: $col_right%; float: right
;\"";
}
}
}
print "<div". $col_id.$col_class.$col_left.$col_right .">";
}else{
print "</div>";
}
?>
%%
==Demo==
~- ""{{col left="DIV"}}{{col left="33"}}First column{{col}}{{col left="34"}}Middle column{{col}}{{col left="33"}}Last column{{col}}{{col}}""
~""<div><div style="width: 33%; float: left;">First column</div><div style="width: 34%; float: left;">Middle column</div><div style="width: 33%; float: left;">Last column</div></div>""

==History==
~- Published on main site (2005-05-09) - OnegWR

==To Do==
~- Add code for text alignment.

----
CategoryUserContributions
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki