我製作了一個小型的magento(1.7)模板文件,用於顯示類別中的所有產品。但是,它們只能顯示在單個列中。我想顯示在2列。用於2列的塊的magento模板
此執行從頭版塊:
{{block type="catalog/product" name="msc.specials" template="mylib/featuredlist.phtml"}}
這是featuredlist.phtml -
<?php
//$_categoryId = $this->getCategoryId();
$productCollection = Mage::getModel('catalog/category')->load(4)
->getProductCollection()
->addAttributeToSelect('*')
->addAttributeToFilter('status', 1)
->addAttributeToFilter('visibility', 4)
->setOrder('price', 'ASC');
$cartHelper = Mage::helper('checkout/cart');
?>
<div class='block block-list'>
<div class='block-title'><strong><span><?php echo $this->__('SPECIALS') ?></span></strong></div>
<div class='block-content'>
<ul>
<h2><?php echo $this->__($this->getLabel()); ?></h2>
<?php foreach ($productCollection as $product): ?>
<div class="item">
<a class="product-image" href="<?php echo $product->getProductUrl() ?>">
<img src="<?php echo $this->helper('catalog/image')->init($product, 'small_image')->resize(100); ?>" alt="<?php echo $this->htmlEscape($this->getImageLabel($product, 'small_image')) ?>" />
</a>
<a class="product-name" href="<?php echo $product->getProductUrl() ?>"><?php echo $this->htmlEscape($product->getName()) ?></a>
<?php echo $this->getPriceHtml($product, true) ?>
</div>
<div class="cms-price-box" style=" text-align:center;"></div>
<div class="button-row" style="text-align:center;">
<button class="button btn-cart" type="button" onclick="setLocation('<?php echo $this->getUrl('')."checkout/cart/add?product=".$product->getId()."&qty=1" ?>')" class="button"><span><?php echo $this->__('Add to Cart') ?></span></button>
</div>
<br/><br/>
<?php endforeach ?>
</ul>
</div>
</div>
我有一些困難夾緊集合,所以我用低科技(($ x%2)== 0)。看到我的答案在下面... –