2011-12-12 103 views
2

我正在处理一个奇怪的问题。在我的产品列表页面中,分页不能正常工作。 我一共有187个项目。在分页中,显示的页面数量是三个。即; 1,2,3 当我选择每页45个记录并选择第4页时,项目加载正确,但分页链接仍显示为1,2,3,4而不是2,3,4。Magento分页 - 每页记录数为45时页码不能正确显示

我现在用的模板是前端\ myCompany的\ DEFAULT \模板\页/ HTML/pager.phtml 和块MageWorx_SeoSuite_Block_Page_Html_Pager。

对于记录数15和30,分页没有任何问题,只有在每页选择45条记录时才会出现问题。

pager.phtml的内容是,

<?php if($this->getCollection()->getSize()): ?> 

<?php if($this->getUseContainer()): ?> 
<div class="pager"> 
<?php endif ?> 

<?php if($this->getShowAmounts()): ?> 
<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> 
<?php endif ?> 

<?php if($this->getShowPerPage()): ?> 
<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 endif ?> 

<?php if($this->getLastPageNum()>1): ?> 
<div class="pages"> 

    <!-- <strong><?php echo $this->__('Page:') ?></strong>--> 
    <ol> 
    <?php if (!$this->isFirstPage()): ?> 
     <li> 
      <a class="previous<?php if(!$this->getAnchorTextForPrevious()): ?> i-previous<?php endif;?>" href="<?php echo $this->getPreviousPageUrl() ?>" title="<?php echo $this->__('Previous') ?>"> 
       <?php if(!$this->getAnchorTextForPrevious()): ?> 
        <img src="<?php echo $this->getSkinUrl('images/pager_arrow_left.gif') ?>" alt="<?php echo $this->__('Previous') ?>" class="v-middle" /> 
       <?php else: ?> 
        <?php echo $this->getAnchorTextForPrevious() ?> 
       <?php endif;?> 
      </a> 
     </li> 
    <?php endif;?> 

    <?php if ($this->canShowFirst()): ?> 
     <li><a class="first" href="<?php echo $this->getFirstPageUrl() ?>">1</a></li> 
    <?php endif;?> 

    <?php if ($this->canShowPreviousJump()): ?> 
     <li><a class="previous_jump" title="" href="<?php echo $this->getPreviousJumpUrl() ?>">...</a></li> 
    <?php endif;?> 

    <?php $i=0;foreach ($this->getFramePages() as $_page):if($i<3): ?> 
     <?php if ($this->isPageCurrent($_page)): ?> 
      <li class="current"><?php echo $_page ?></li> 
     <?php else: ?> 
      <li><a href="<?php echo $this->getPageUrl($_page) ?>"><?php echo $_page ?></a></li> 
     <?php endif;?> 
    <?php $i++;endif; endforeach;?> 


    <?php if ($this->canShowNextJump()): ?> 
     <li><a class="next_jump" title="" href="<?php echo $this->getNextJumpUrl() ?>">...</a></li> 
    <?php endif;?> 

    <?php if ($this->canShowLast()): ?> 
     <li><a class="last" href="<?php echo $this->getLastPageUrl() ?>"><?php echo $this->getLastPageNum() ?></a></li> 
    <?php endif;?> 

    <?php if (!$this->isLastPage()): ?> 
     <li> 
      <a class="next<?php if(!$this->getAnchorTextForNext()): ?> i-next<?php endif; ?>" href="<?php echo $this->getNextPageUrl() ?>" title="<?php echo $this->__('Next') ?>"> 
       <?php if(!$this->getAnchorTextForNext()): ?> 
        <img src="<?php echo $this->getSkinUrl('images/pager_arrow_right.gif') ?>" alt="<?php echo $this->__('Next') ?>" class="v-middle" /> 
       <?php else: ?> 
        <?php echo $this->getAnchorTextForNext() ?> 
       <?php endif;?> 
      </a> 
     </li> 
    <?php endif;?> 
    </ol> 

</div> 
<?php endif; ?> 

<?php if($this->getUseContainer()): ?> 
</div> 
<?php endif ?> 

我是一个初学者到Magento的。

回答

2

我修复了这个问题。 在Mage_Page_Block_Html_Pager类有一个受保护的变量$ _displayPages,它被设置为

protected $_displayPages = 5; // Page length for the navigation 

所以在我pager.html(前端\ myCompany的\ DEFAULT \模板\页面\ HTML \ pager.phtml)我做了一个小的变化如下

<?php $i=0;foreach ($this->getFramePages() as $_page):if($i<5): ?> 

我们可以根据我们的要求简单地改变页面的长度。为此,只需重写Mage_Page_Block_Html_Pager类并更改受保护的$ _displayPages变量。

我们还可以设置管理页面的长度