Column Macro (Velocity)
Last modified by Andreea Popescu on 2024/07/05 17:50
Create columns in the content of a page |
Type | Doc (Velocity Macro) |
Category | |
Developed by | xwiki:XWiki.ThomasEveilleau |
Rating | |
License | GNU Lesser General Public License 2.1 |
Table of contents
Description
Usage
#column(number of columns, justify, border)
Parameters definition
Name | Optional | Allowed values | Default value | Description |
---|---|---|---|---|
Number of columns | no | 2,3,4 | none | Number of columns you want to display |
Justify | yes | true | none | "true" to justify the text |
Border | yes | true | none | "true" to add borders (black, 1px, solid) |
Example
#column("2" "true" "false")
content of my first column
#endcolumn()
#column("2" "true" "false")
content of my second column
#endcolumn()
content of my first column
#endcolumn()
#column("2" "true" "false")
content of my second column
#endcolumn()
Result
Prerequisites & Installation Instructions
This a Velocity macro. Since it's not bundled by default you'll have to copy/paste the following code to use it:
#macro(column $columns $justify $border)
#if($columns==2)
#set($width="48%")
#elseif($columns==3)
#set($width="32%")
#elseif($columns==4)
#set($width="23%")
#else
#set($width="23%")
#end
<div style="float:left;width:${width};padding:5px;#if($justify=="true")text-align:justify;#end #if($border=="true")border:1px solid black;#end">
#end
#macro(endcolumn)
</div>
#end
#if($columns==2)
#set($width="48%")
#elseif($columns==3)
#set($width="32%")
#elseif($columns==4)
#set($width="23%")
#else
#set($width="23%")
#end
<div style="float:left;width:${width};padding:5px;#if($justify=="true")text-align:justify;#end #if($border=="true")border:1px solid black;#end">
#end
#macro(endcolumn)
</div>
#end