Magento:将“产品列表传呼机"块放在< head>中 [英] Magento: Put "product list pager"-block in <head>
本文介绍了Magento:将“产品列表传呼机"块放在< head>中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下问题:我想为gengento产品列表使用rel ="next"和rel ="prev"开发分页. http://googlewebmastercentral.blogspot.com/2011/09/pagination-with-relnext-and-relprev.html 如何访问中的寻呼机?当将渲染分页块时,头块已经被渲染了.
I have the following problem: I want develop Pagination with rel="next" and rel="prev" for magento product lists. http://googlewebmastercentral.blogspot.com/2011/09/pagination-with-relnext-and-relprev.html How can I access the pager in ? The head-block has been already rendered when the pager-block will be rendered...
我的问题有解决方案吗?
Is there any solution for my problem?
推荐答案
从1.5版开始,此解决方案不再起作用,这是我的解决方案:
From version 1.5 this solution doesn't work anymore, this is my solution:
$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 .'" />';
}
这篇关于Magento:将“产品列表传呼机"块放在< head>中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文