rel="next" and rel="prev" for magento pagination
Hello I want to put the rel=“next” and rel=“prev” tag for category pagination into the <head> </head> section of my magento website. For detials on the rel=“next” and rel=“prev” tag see http://googlewebmastercentral.blogspot.com/2011/09/pagination-with-relnext-and-relprev.html.

I am using the code from shadowice222 posted on http://stackoverflow.com/questions/7609866/magento-put-product-list-pager-block-in-head.

        <?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
        }
    ?>

I got the problem, that on my second paginated page the is a 

        <link rel="prev" href="http://www.website.de/category1.html?p=1" />

This should be 

         <link rel="prev" href="http://www.website.de/category1.html" />

like the normal category url, which is the normal first page. Otherwise Google will be confused. Can anybody help me out in just changing the rel="prev" tag from the second to the first page. Everything else is working just fine. Thank you very much in advance.




rel="next" and rel="prev" for magento pagination
===

Hello I want to put the rel=“next” and rel=“prev” tag for category pagination into the <head> </head> section of my magento website. For detials on the rel=“next” and rel=“prev” tag see http://googlewebmastercentral.blogspot.com/2011/09/pagination-with-relnext-and-relprev.html.

I am using the code from shadowice222 posted on http://stackoverflow.com/questions/7609866/magento-put-product-list-pager-block-in-head.

        <?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
        }
    ?>

I got the problem, that on my second paginated page the is a 

        <link rel="prev" href="http://www.website.de/category1.html?p=1" />

This should be 

         <link rel="prev" href="http://www.website.de/category1.html" />

like the normal category url, which is the normal first page. Otherwise Google will be confused. Can anybody help me out in just changing the rel="prev" tag from the second to the first page. Everything else is working just fine. Thank you very much in advance.



