PHP Problem
Geizhals » Forum » Programmierung » PHP Problem (8 Beiträge, 122 Mal gelesen) Top-100 | Fresh-100
Du bist nicht angemeldet. [ Login/Registrieren ]
PHP Problem
22.03.2010, 20:43:32
Hallo,

leider hab ich (fast) keine Ahnung von PHP und benötige Hilfe.
Konkret geht es darum, dass im Webshop 3 Produkte in einer Zeile dargestellt werden. Es sollen aber nur 2 Produtkte pro Zeile sein.

Das Problem ist, dass ich nicht weiß, was ich am Code ändern muss, damit nach jedem zweiten Produkt ein <tr> für eine neue Zeile erhalten.
Die abschließenden </tr> Tags sollen natürlich auch nicht fehlen.

Für Hilfe wäre ich sehr dankbar.



<?php $_collectionSize = $_productCollection->count() ?>
    <table class="products-grid" id="products-grid-table">
    <?php $_columnCount = $this->getColumnCount(); ?>
    <?php $i=0; foreach ($_productCollection as $_product): ?>
        <?php if ($i++%$_columnCount==0): ?>
        <tr>
        <?php endif ?>
            <td>
                <h2><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>">
					<span class="product-image">
						<img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(135, 135); ?>" width="135" height="135" alt="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>" title="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>" />
					</span>
					<span class="product-name"><?php echo $this->htmlEscape($_product->getName())?></span>
				</a></h2>
                <?php if($_product->getRatingSummary()): ?>
                <?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
                <?php endif; ?>
                <?php echo $this->getPriceHtml($_product, true) ?>
                <?php if($_product->isSaleable()): ?>
                &lt;button type="button" class="button" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"&gt;<span><?php echo $this->__('Add to Cart') ?></span></button>
                <?php else: ?>
                <p class="availability"><span class="out-of-stock"><?php echo $this->__('Out of stock') ?></span></p>
                <?php endif; ?>
                <ul class="add-to-links">
                    <?php if ($this->helper('wishlist')->isAllow()) : ?>
                        <li><a href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>" rel="nofollow"><?php echo $this->__('Add to Wishlist') ?></a></li>
                    <?php endif; ?>
                    <?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
                        <li><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" rel="nofollow"><?php echo $this->__('Add to Compare') ?></a></li>
                    <?php endif; ?>
                </ul>
            </td>
        <?php if ($i%3==0 && $i!=$_collectionSize): ?>
        </tr>
        <?php endif ?>
        <?php endforeach ?>
        <?php for($i;$i%3!=0;$i++): ?>
              <td class="empty">&nbsp;</td>
        <?php endfor ?>
        <?php if ($i%3==0): ?>
        </tr>
        <?php endif ?>
    </table>
    
    <?php endif; ?>
    <?php echo $this->getToolbarHtml() ?>
</div>
<?php endif; ?>


Antworten PM Übersicht Chronologisch
 
Melden nicht möglich
 

Dieses Forum ist eine frei zugängliche Diskussionsplattform.
Der Betreiber übernimmt keine Verantwortung für den Inhalt der Beiträge und behält sich das Recht vor, Beiträge mit rechtswidrigem oder anstößigem Inhalt zu löschen.
Datenschutzerklärung