Code help.

Hey all. PHP is on the list of things I need to become more familiar with. Unfortunately I’ve not had time, but I don’t have the need to write it to much.

I am using Joomla, Virtuemart and K2 Mart… My product options are all displaying in one table row. I need to be able to make it jump to a second row after 2 or 3 columns.

Here is the page example, you can see the little individual quantity areas and the exterior color option. I’d really appreciate any help you can all give me, especially if the code is easy so I can change the number of columns before creating a new row if I need to.

[php]
<?php if($this->params->get('listingCartProductFields') && !empty($product->customFieldsCart)): ?>



<?php foreach ($product->customFieldsCart as $field): ?>

<?php endforeach;?>



<?php echo JText::_($field->custom_title); ?>
<?php if ($field->custom_tip): ?>
<?php echo JText::_($field->custom_tip);?>
<?php endif; ?>


<?php echo $field->display; ?>
<?php echo $field->custom_field_desc; ?>


<?php endif;?>[/php]

Replace this line:
[php]<?php foreach ($product->customFieldsCart as $field): ?>[/php]

with the following:
[php]

<?php $tc_count = 1; $tc_max = 3; // adjust this to allow more/less columns. foreach ($product->customFieldsCart as $field): if($tc_count >= $tc_max) { print ''; $tc_count=0; } $tc_count++; ?>[/php]

Should help you achieve what you’re trying to do.
Red :wink:

Sponsor our Newsletter | Privacy Policy | Terms of Service