1

如何仅在产品列表底部插入寻呼机?

在我想要的产品列表顶部:“按相关性/畅销书/等排序”和“按:表/列表排序项目”,这是我能够做到的。

在产品列表的底部我只想要寻呼机,我尝试在 list.phtml 中插入以下代码

<?php echo $this->getPagerHtml() ?>

但是这个 php 代码不能直接在产品列表上工作。

如何使寻呼机在产品列表上工作并显示在底部?

4

3 回答 3

2

您好,您使用以下代码创建新的 toolbar-bottom.phtml 文件,即 app/design/frontend/(base or default)/(default or yourtheme)/template/catalog/product/list/toolbar-bottom.phtml

<?php if ($this->getCollection()->getSize()): ?>
    <div class="toolbar">
        <div class="pager"> 
            <p class="amount"> 
                <?php if ($this->getLastPageNum() > 1): ?> 
                    <?php echo $this->__('Items %s to %s of %s total', $this->getFirstNum(), $this->getLastNum(), $this->getTotalNum()) ?>
                <?php else: ?> 
                    <strong>
                        <?php echo $this->__('%s Item(s)', $this->getTotalNum()) ?>
                    </strong>
                <?php endif; ?> </p> 
            <div class="limiter"> 
                <label><?php echo $this->__('Show') ?></label> 
                <select onchange="setLocation(this.value)"> 
                    <?php foreach ($this->getAvailableLimit() as $_key => $_limit): ?> 
                        <option value="<?php echo $this->getLimitUrl($_key) ?>"<?php if ($this->isLimitCurrent($_key)): ?> selected="selected"
                        <?php endif ?>
                        <?php echo $_limit ?> 
                    </option> 
                <?php endforeach; ?>
            </select>
            <?php echo $this->__('per page') ?> </div> <?php
        echo
        $this->getPagerHtml()
        ?>
    </div>
    </div>
    <?php  endif ?>

调用app/design/frontend/(base or default)/(default or yourtheme)/template/catalog/product/list.phtml 中的行底

getToolbarBlock()->setTemplate('catalog/product/list/toolbar-bottom.phtml')->toHtml();

于 2012-12-18T06:02:00.493 回答
1

您可以通过以下两种方式之一执行此操作。

1) 使用 CSS

<div class="category-products">
   <div class='top-toolbar'><?php echo $this->getToolbarHtml() ?></div>

 ...
   <div class='bottom-toolbar'><?php echo $this->getToolbarHtml() ?></div>
</div>

在 CSS 中

 .bottom-toolbar .xyz{
    display:none;
 }

2)使用自定义模块覆盖getToolbarHtml

$this->getToolbarHtml('top-toolbar');

$this->getToolbarHtml('bottom-toolbar');


public function getToolbarHtml($toolbar_position)
{   
    $this->toolbar_position = $toolbar_position;
    return $this->getChildHtml('toolbar');
}

然后尝试传递$this->toolbar_position到每个块以显示您需要的部分

于 2012-12-18T19:37:08.800 回答
0

我想这就是你想要的。

$toolbar = $this->getToolbarBlock();
$toolbar->setCollection($_productCollection);
if($toolbar->getCollection()->getSize() > 0):
echo $toolbar->getPagerHtml(); //Pager
echo $toolbar-> __('Items %s to %s of %s total', $toolbar->getFirstNum(), $toolbar->getLastNum(),
$toolbar ->getTotalNum());
endif;

字体: http: //mayankpatel104.blogspot.com.br/2012/07/magento-pagination-without-toolbar.html

于 2014-11-18T20:13:39.470 回答