Hallo,
dein Vorhaben es manuell über HTML in die Datei zu coden wird sich als recht programmieraufwendig erweisen, da du die ganzen Inhalte der Selects dann auch manuell mit in den Warenkorb schicken musst, um sie dort anzeigen zu lassen.
Falls du bei deinen Produkten wirklich IMMER nur "Rechts" und dann 4 Attribute daneben aufgelistet haben möchtest und darunter "Links" und wieder 4 Attribute kommen sollen, dann wäre das ziemlich einfach zu programmieren, aber lässt dann KEINERLEI Flexibilität mehr zu, was die Attribute angeht.
im Urzustand sollte deine "addtocart_advanced_attribute.tpl.php" ja so aussehen:
PHP-Code:
<?php if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );
foreach($attributes as $attribute) {
?>
<div class="vmAttribChildDetail" style="float: left;text-align:right;margin:3px;">
<label for="<?php echo $attribute['titlevar'] ?>_field"><?php echo $attribute['title'] ?></label>:
</div>
<div class="vmAttribChildDetail" style="float:left;margin:3px;">
<select class="inputboxattrib" id="<?php echo $attribute['titlevar'] ?>_field" name="<?php echo $attribute['titlevar'].$attribute['product_id'] ?>">
<?php foreach ( $attribute['options_list'] as $options_item ) : ?>
<?php if( isset( $options_item['display_price']) ) : ?>
<option value="<?php echo $options_item['base_var'] ?>"><?php echo $options_item['base_value'] ?> (<?php echo $options_item['sign'].$options_item['display_price'] ?>)</option>
<?php else : ?>
<option value="<?php echo $options_item['base_var'] ?>"><?php echo $options_item['base_value'] ?></option>
<?php endif; ?>
<?php endforeach; ?>
</select>
</div>
<br style="clear:both;" />
<?php
} ?>
etwas umgecodet in diese Richtung:
PHP-Code:
<?php if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );
$i=0;
foreach($attributes as $attribute) {
$i++;
if($i == 1){
echo '<div style="float:left;margin:3px;">Rechts:</div>';
}
?>
<div class="vmAttribChildDetail" style="float: left;text-align:right;margin:3px;">
<label for="<?php echo $attribute['titlevar'] ?>_field"><?php echo $attribute['title'] ?></label>:
</div>
<div class="vmAttribChildDetail" style="float:left;margin:3px;">
<select class="inputboxattrib" id="<?php echo $attribute['titlevar'] ?>_field" name="<?php echo $attribute['titlevar'].$attribute['product_id'] ?>">
<?php foreach ( $attribute['options_list'] as $options_item ) : ?>
<?php if( isset( $options_item['display_price']) ) : ?>
<option value="<?php echo $options_item['base_var'] ?>"><?php echo $options_item['base_value'] ?> (<?php echo $options_item['sign'].$options_item['display_price'] ?>)</option>
<?php else : ?>
<option value="<?php echo $options_item['base_var'] ?>"><?php echo $options_item['base_value'] ?></option>
<?php endif; ?>
<?php endforeach; ?>
</select>
</div>
<?php
if(($i % 4) == 0){
echo '<br style="clear:both"/>';
}
if($i == 4){
echo '<div style="float:left;margin:3px;">Links:</div>';
}
}
?>
wäre jetzt auf deinen speziellen, als Bild angehangenen Fall angepasst. Was hier passiert wäre folgendes...die Variable "$i" wird zu Beginn auf den Wert "0" gesetzt. Mit jeder Ausgabe eines Attributs wird "1" dazu addiert. Falls "$i" den Wert "1" hat, wird das Wort "Rechts:" ausgegeben und nachfolgend werden nebeneinander genau 4 Attribute ausgegeben. Falls "$i" den Wert "4" hat, wird das Wort "Links:" ausgegeben. Im Anschluss kommen wieder 4 Attribute. Falls "$i" geteilt durch 4 keinen Rest hat, wird ein Zeilenumbruch erzwungen.
Lesezeichen