Hello Everyone,
I am trying to build an HTML table using channel entries. In other words, I’d like to create a row every three entries.
Has anyone done this before?
Thanks in advance for your time and help.
Thank you,
Mario
This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.
The active forums are here.
November 05, 2010 6:31pm
Subscribe [3]#1 / Nov 05, 2010 6:31pm
Hello Everyone,
I am trying to build an HTML table using channel entries. In other words, I’d like to create a row every three entries.
Has anyone done this before?
Thanks in advance for your time and help.
Thank you,
Mario
#2 / Nov 08, 2010 6:06am
I would recommend using the matrix field-type add-on.
http://pixelandtonic.com/matrix
Create 3 columns and add in template code like:
<table>
{matrix_field_name}
<tr>
<td>{col_1_name}</td>
<td>{col_2_name}</td>
<td>{col_3_name}</td>
</tr>
{/matrix_field_name}
</table>#3 / Nov 11, 2010 12:34am
Matrix is great. If you need to make a table out of your entries, though, you can use a dash of PHP to display alternating row classes every 2, 3, 4, or whatever # rows. This one is set to 5.
{!-- Quick modulus operator to get new row after 5 images --}
<?php
$count = '{count}';
if($count % 5 == 0) {echo('<tr class="whatever">'); }
?>#4 / Nov 11, 2010 10:43am
Thank you for your help.
I used PHP to generate the table.
Mario