Column Macro (Velocity)

Last modified by Andreea Popescu on 2021/03/17 21:17

cogCreate columns in the content of a page
TypeDoc (Velocity Macro)
Category
Developed by

xwiki:XWiki.ThomasEveilleau

Rating
0 Votes
LicenseGNU Lesser General Public License 2.1

Description

This macro is for syntax 1.0. For syntax 2.0, this macro should be preferred

Usage

#column(number of columns, justify, border)

Parameters definition

NameOptionalAllowed valuesDefault valueDescription
Number of columnsno2,3,4noneNumber of columns you want to display
Justifyyestruenone"true" to justify the text
Borderyestruenone"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()

Result

2columns.png

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

Get Connected