2011-09-30 30 views

回答

1

是的,你可以做編輯以下文件:

/app/design/frontend//default/template/page/html/pager.phtml

在那裏你看到,例如:

<?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 echo $this->__("Previous");?> 
       </a> 
      </li> 
     <?php endif;?> 

您可以在其中的rel =「...」你想輕鬆地添加到鏈接,同樣適用於‘下一步’鏈接;)

+0

我已經知道了模板。但我必須在標題標籤處添加鏈接標籤。在模板pager.phtml中是不可能的。 – timopeschka

1

我加入這個合作德成head.phtml文件...

<?php 
     $actionName = $this->getAction()->getFullActionName(); 
     if($actionName == 'catalog_category_view') // Category Page 
     { 
      $id = Mage::app()->getRequest()->getParam('id', false); //cat id 
      $category = Mage::getModel('catalog/category')->load($id); 
      $prodCol = $category->getProductCollection(); 
      $tool = $this->getLayout()->createBlock('catalog/product_list_toolbar')->setCollection($prodCol); 
      $linkPrev = false; 
      $linkNext = false; 
      if ($tool->getCollection()->getSize()) { 
       if ($tool->getLastPageNum() > 1) { 
        if (!$tool->isFirstPage()) { 
         $linkPrev = true; 
         $prevUrl = $tool->getPreviousPageUrl(); 
        } 
        if (!$tool->isLastPage()) { 
         $linkNext = true; 
         $nextUrl = $tool->getNextPageUrl(); 
        } 
       } 
      } 
      ?> 
      <?php if ($linkPrev): ?> 
      <link rel="prev" href="<?php echo $prevUrl ?>" /> 
      <?php endif; ?> 
      <?php if ($linkNext): ?> 
      <link rel="next" href="<?php echo $nextUrl ?>" /> 
      <?php endif; ?> 
    <?php 
     } 
    ?> 
1

從1.5版本的解決方案不工作了,這是我的解決方案:

$actionName = $this->getAction()->getFullActionName(); 
if($actionName == 'catalog_category_view') // Category Page 
{ 
    $id = Mage::app()->getRequest()->getParam('id', false); //cat id 
    $category = Mage::getModel('catalog/category')->load($id); 
    $prodCol = $category->getProductCollection()->addAttributeToFilter('status', 1)->addAttributeToFilter('visibility', array('in' => array(2, 4))); 
    $tool = $this->getLayout()->createBlock('page/html_pager')->setLimit($this->getLayout()->createBlock('catalog/product_list_toolbar')->getLimit())->setCollection($prodCol); 
    $linkPrev = false; 
    $linkNext = false; 
    if ($tool->getCollection()->getSize()){ 
     if ($tool->getLastPageNum() > 1){ 
      if (!$tool->isFirstPage()) { 
       $linkPrev = true; 
       if($tool->getCurrentPage()==2){ 
        $url = explode('?',$tool->getPreviousPageUrl()); 
        $prevUrl = $url[0]; 
       } 
       else $prevUrl = $tool->getPreviousPageUrl(); 
      } 
      if (!$tool->isLastPage()){ 
       $linkNext = true; 
       $nextUrl = $tool->getNextPageUrl(); 
      } 
     } 
    } 
    if ($linkPrev) echo '<link rel="prev" href="'. $prevUrl .'" />'; 
    if ($linkNext) echo '<link rel="next" href="'. $nextUrl .'" />'; 
}