I have approximately 20 content-taxonomy check boxes from one field ("features"). The checked terms display in node-example.tpl.php. I am trying to show these content-taxonomy terms in two columns displayed/sorted in a downward order instead of across.
I am trying to cobble two bits of code to accomplish this...but my php skills are not yet up to the challenge. I can't get all of the array values generated in the foreach loop to be recognized by the second section of code.
The code below was taken (and modified) from the following sources:
roscripts.com/PHP_display_data_on_columns-127.html
I am trying to use the following code in my node-example.tpl.php file.
<?php
echo '<table>';
foreach ($node->field_features as $delta => $value){
$term = taxonomy_get_term($node->field_features[$delta]['value']);
$term_name = check_plain($term->name);
}
// Default # of Columns
$numcols = 2;
// Number of Items
$numitems = count($term_name);
// Number of Rows
$numrows = ceil($numitems/$numcols);
for ($row=1; $row <= $numrows; $row++)
{
$cell = 0;
echo ' <tr>'."\n";
for ($col=1; $col <= $numcols; $col++)
{
echo ' <td>'."\n";
if ($col===1)
{
$cell += $row;
print $term_name[$cell - 1];
}
else {
$cell += $numrows;
print $term_name[$cell - 1];
}
echo ' </td>'."\n";
}
echo ' </tr>'."\n";
}
echo '</table>';
?>