Magento – How to get total number of pages in list.phtml

category-productslist.phtmlmagento-1.9pager

In magento 1.9.2.3 at the category of products I have two toolbars.
At top toolbar I need only "Previous" and "Next" link.
At the bottom toolbar I need "Total of Pages", "1, 2, 3 … n-th nubmer of pages with link", and "Previous" and "Next" link.
I create my new theme and template.
From list.phtml I can get the block of pager.phtml with this code:

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

But I need to obtain diferite template of pager.phtml for top-toolbar and for bottom-toolbar, how can I add a new template of pager.phtml?

Best Answer

So, I have created a new file toolbar-bottom.phtml and insert this code:

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

And in the list.phtml I insert this code:

<?php echo $this->getToolbarBlock()->setTemplate('catalog/product/list/toolbar-bottom.phtml')->toHtml(); ?>

And in toolbar.phtml I insert this code:

<?php $pagerBlock = $this->getChild('product_list_toolbar_pager');
                if($pagerBlock->getLastPageNum()>1): ?>
                    <div class="pagination_nav pagination_nav--small">

                    <?php if (!$pagerBlock->isFirstPage()): ?>
                        <a  href="<?php echo $pagerBlock->getPreviousPageUrl() ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Previous')) ?>">
                            <?php echo $this->__('&lt; Previous') ?>
                        </a>
                    <?php else:?>
                        <span  class="disabled"><?php echo $this->__('&lt; Previous') ?></span >
                    <?php endif;?>

                    <?php

                    if (!$pagerBlock->isLastPage()): ?>
                        <a href="<?php echo $pagerBlock->getNextPageUrl() ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Next')) ?>">
                            <?php echo $this->__('Next &gt;') ?>
                        </a>
                    <?php else:?>
                        <span class="disabled"><?php echo $this->__('Next &gt;') ?></span>
                    <?php endif;?>
                    </div>
                <?php endif;?>
Related Topic