我一直试图制作一个功能性主页产品网格,共显示9个产品,但我没有显示3行3个产品,我得到3/1/3/2而且我不明白这是为什么。
这是我正在做的开发领域,在家里你会看到网格。应该有9个产品,然后单击箭头查看更多。
以下是/app/design/frontend/mytheme/template/catalog/product/featured.phtml中的featured.phtml文件
<?php
/**
* Product list template
*
* @see Mage_Catalog_Block_Product_List
*/
?>
<?php
$_productCollection=$this->getLoadedProductCollection();
$_helper = $this->helper('catalog/output');
$page = Mage::app()->getLayout()->getBlock('root')->getTemplate();
$newsaleicon = Mage::helper("ExtraConfig")->themeOptions('newsaleicon');
$ajaxcart = Mage::helper("ExtraConfig")->themeOptions('ajaxcart');
?>
<div class="featured-product">
<div class="new-arrow">
<h2 class="page-title subtitle"><?php echo $this->__('Featured Products') ?></h2>
</div>
<?php if($_productCollection->count()): ?>
<?php $_collectionSize = $_productCollection->count() ?>
<div class="slider2">
<?php if($page == 'page/1column.phtml') { ?>
<?php $columnCount = 8; $this->setColumnCount($columnCount); $_columnCount = $this->getColumnCount(); ?>
<?php } else { ?>
<?php $columnCount = 9; $this->setColumnCount($columnCount); $_columnCount = $this->getColumnCount(); ?>
<?php } ?>
<?php $i=0;$j=0; foreach ($_productCollection as $_product): ?>
<?php if ($i++%$_columnCount==0): ?>
<?php if($page == 'page/1column.phtml') { ?>
<ul class="products-grid products-grid-full">
<?php } elseif($page == 'page/2columns-right.phtml' || $page == 'page/2columns-left.phtml') { ?>
<ul class="products-grid products-grid-side">
<?php } else { ?>
<ul class="products-grid products-grid-middle">
<?php } ?>
<?php endif; ?>
<li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
<div class="content_top">
<?php if($newsaleicon == '1') { ?>
<?php $adate = date('Y-m-d'); //echo 'frpm:-'.$_product->special_from_date.'----';echo "to:-".$_product->special_to_date.'--';
$a= 0;
if($_product->special_from_date != null && $_product->special_to_date == "")
{
if( $adate >= $_product->special_from_date)
{
$a = 1;
}
}
if($_product->special_from_date != "" && $_product->special_to_date != "")
{
if($adate >= $_product->special_from_date && $adate <= $_product->special_to_date)
{
$a = 1;
}
}
if($a == 1){ ?>
<div class="sale"><label><?php echo $this->__('SALE') ?></label></div>
<?php } ?>
<?php $bdate = date('Y-m-d');
$b= 0;
if($_product->news_from_date != null && $_product->news_to_date == "")
{
if( $bdate >= $_product->news_from_date)
{
$b = 1;
}
}
if($_product->news_from_date != "" && $_product->news_to_date != "")
{
if($bdate >= $_product->news_from_date && $bdate <= $_product->news_to_date)
{
$b = 1;
}
}
if($b == 1){ ?>
<div class="new"><label><?php echo $this->__('NEW') ?></label></div>
<?php }
?>
<?php } ?>
<?php if($ajaxcart == '2') { ?>
<a href='<?php echo $this->getUrl('ajax/index/options',array('product_id'=>$_product->getId()));?>' class='fancybox quick-view' id='fancybox<?php echo $_product->getId()?>'><div class="tooltip"><?php echo $this->__('Quick View') ?><div class="errow"></div></div></a>
<?php } ?>
<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image">
<img class="small-image" src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(430) ?>" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />
<img class="thumbnail" src="<?php echo $this->helper('catalog/image')->init($_product, 'thumbnail')->resize(430) ?>" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />
</a>
<div class="productname">
<?php if($page == 'page/3columns.phtml') { ?>
<?php $productName = $this->htmlEscape($_product->getName());
if(strlen($productName) > 18) {
$productName = mb_strimwidth($productName,0,18,"...",'utf-8');
} ?>
<?php } else { ?>
<?php $productName = $this->htmlEscape($_product->getName());
if(strlen($productName) > 30) {
$productName = mb_strimwidth($productName,0,30,"...",'utf-8');
} ?>
<?php } ?>
<h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>"><?php echo $productName; ?></a></h2>
</div>
</div>
<div class="productgrid-area">
<div class="vert">
<?php echo $this->getPriceHtml($_product, true) ?>
</div>
<?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
<div class="actions">
<?php if($_product->isSaleable()): ?>
<?php if($ajaxcart == '1' || $ajaxcart == '2') { ?>
<?php if ( !($_product->getTypeInstance(true)->hasRequiredOptions($_product) || $_product->isGrouped()) ) { ?>
<div class="ajax-button">
<button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart ajx-cart" onclick="setLocationAjax1('<?php echo $this->getAddToCartUrl($_product) ?>','<?php echo $_product->getId()?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
<div id='ajax_loader1<?php echo $_product->getId()?>' class="ajaxcartpro_progress" style="display: none;">
<img src="<?php echo $this->getSkinUrl('ajaxcart/images/al.gif'); ?>">
</div>
</div>
<?php } else { ?>
<button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
<?php } ?>
<?php } else { ?>
<button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
<?php } ?>
<?php else: ?>
<p class="availability out-of-stock"><span><?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) ?>" title="<?php echo $this->__('Add to Wishlist') ?>" class="link-wishlist"><div class="tooltip"><?php echo $this->__('Add to Wishlist') ?><div class="errow"></div></div></a></li>
<?php endif; ?>
<?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
<li><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" title="<?php echo $this->__('Add to Compare') ?>" class="link-compare"><div class="tooltip"><?php echo $this->__('Add to Compare') ?><div class="errow"></div></div></a></li>
<?php endif; ?>
</ul>
</div>
</div>
</li>
<?php if ($i%$_columnCount==0 || $i==$_collectionSize): ?>
</ul>
<?php endif; ?>
<?php endforeach ?>
</div>
<script type="text/javascript">decorateGeneric($$('ul.products-grid'), ['odd','even','first','last'])</script>
<?php endif; ?>
</div>
我相信这是影响结果的线,但即使我尝试3的不同倍数,它似乎总是错误的:
<?php $columnCount = 9; $this->setColumnCount($columnCount); $_columnCount = $this->getColumnCount(); ?>
以下是我认为相关的一小部分CSS:
.featured-product .products-grid-side li.item:first-child + li + li,
.featured-product .products-grid-side li.item:first-child + li + li + li + li + li,
我不确定问题是什么,但如果您知道我非常感谢您的帮助,请提前感谢:)
此外,这是Magento 1.8.1
答案 0 :(得分:1)
哦,你的漂浮物在上面的上面徘徊。我建议一些
.products-grid-side li.item {
height: 400px;
}
让他们按照你的意愿行事。
我喜欢你的主页布局。