Looking to create a 4×10 table that lists my array in velocity using a foreach loop

I want to loop through an array listing [1-4] in the first row, [5-8] in the second and continue till the entire array is output.

#set ($cats = ["Accounting", "Admin & Clerical", "Automotive", "Banking", "Broadcast - Journalism", "Business Development", "Construction", "Customer Service", "Design", "Distribution - Shipping", "Education - Teaching", "Facilities", "Finance", "General Business", "General Labor", "Government", "Grocery", "Health Care", "Hotel - Hospitality", "Human Resources", "Installation - Maint - Repair", "Inventory", "Legal Admin", "Management", "Manufacturing", "Marketing", "Nurse", "Pharmaceutical", "Purchasing - Procurement", "QA - Quality Control", "Real Estate", "Research", "Restaurant - Food Service", "Retail", "Sales", "Skilled Labor - Trades", "Strategy - Planning", "Supply Chain", "Transportation", "Warehouse"] )

<table cellpadding="5px" cellspacing="0" width="100%" style="width:100%!important;font-size:9px;font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif;font-weight:normal;text-align:center;background:;color:black">
#set ($counter = 0)
#set ($j = )
#foreach ($i in $cats)
    #if ( $counter % 2 == 0)
	<tr>
		<td>$i</td>
		<td></td>
		<td></td>
		<td></td>
	</tr>
    #else
	<tr>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
	</tr>
    #end
#end

</table>


Source: apache

Leave a Reply