public function product_types_nav() { $output = ''; $types = ProductType::nav(); $output .= '<table class="ecommerce types">'; $i = 0; $col_num = 4; foreach ($types as $type) { if ($i % $col_num == 0) { if ($i > 1) { $output .= '</tr>'; $i = 0; } $output .= '<tr>'; } $output .= '<td><a href="/products/types/' . $type->slug . '">' . $type->title . '</a></td>'; $i++; } while ($i % $col_num != 0) { $output .= '<td> </td>'; $i++; } $output .= '</tr></table>'; return $output; }