gpt4 book ai didi

php - 将上一个和下一个按钮添加到类别产品

转载 作者:太空宇宙 更新时间:2023-11-04 04:20:54 25 4
gpt4 key购买 nike

我使用以下 block 在主页中显示类别产品。{{block type="catalog/product_list"template="catalog/product/home_short.phtml"category_id="5"column_count="6"}}。现在我需要在产品列表和我的代码中添加上一个和下一个按钮是

<?php $_productCollection=$this->getLoadedProductCollection() ?>
<?php if(!$_productCollection->count()): ?>
<p class="note-msg"><?php echo $this->__('There are no products matching the selection.') ?></p>
<?php else: ?>
<div class="category-products">

<?php // Grid Mode ?>

<?php $_collectionSize = $_productCollection->count() ?>
<?php $_columnCount = $this->getColumnCount(); ?>
<?php $i=0; foreach ($_productCollection as $_product): ?>
<?php if ($i++%$_columnCount==0): ?>
<ul class="products-grid">
<?php endif ?>
<li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>" 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')) ?>" /></a>
<h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>"><?php echo $this->htmlEscape($_product->getName()) ?></a></h2>
<?php echo $this->getPriceHtml($_product, true) ?>
<div class="actions">
<?php if($_product->isSaleable()): ?>
<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 else: ?>
<p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
<?php endif; ?>
</div>
</li>
<?php if ($i%$_columnCount==0 || $i==$_collectionSize): ?>
</ul>
<?php endif ?>
<?php endforeach ?>
<script type="text/javascript">decorateGeneric($$('ul.products-grid'), ['odd','even','first','last'])</script>
</div>
<?php endif; ?>

最佳答案

  1. 转到 CMS > 管理页面并点击主页。
  2. 在“设计”选项卡下,在“更新布局 XML”字段中插入以下代码。

    <reference name="content">
    <block type="catalog/product_list" name="product_list" template="catalog/product/home_short.phtml">
    <action method="setCategoryId"><category_id>5</category_id></action>
    <action method="setCategoryId"><category_id>6</category_id></action>
    <block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
    <block type="page/html_pager" name="product_list_toolbar_pager"/>
    </block>
    <action method="setToolbarBlockName"><name>product_list_toolbar</name></action>
    </block>
    </reference>

magento 根据您的产品数量自动划分页面并使用上一页和下一页按钮设置分页

关于php - 将上一个和下一个按钮添加到类别产品,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19093278/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com