Page 1 of 1

Zend framework <link rel="next"> and <link rel="prev">"

Posted: Sat Oct 26, 2013 7:41 am
by roma2509
I have a site, better to say an online shop. On it I have the pages for categories. Each category with products how it is normal have pagination. The SEO rules says that to not confuse Google we need to put on this pages of categories for example the <link rel="next" href="http://www.example.com/article?story=abc&page=2" /> in <head>.
My question is how to do this if my pages are created dynamically. How can I do this for dynamic pages:

On the first page, http://www.example.com/article?story=abc&page=1, you’d include in the <head> section:
<link rel="next" href="http://www.example.com/article?story=abc&page=2" />

On the second page, http://www.example.com/article?story=abc&page=2:

<link rel="prev" href="http://www.example.com/article?story=abc&page=1" />
<link rel="next" href="http://www.example.com/article?story=abc&page=3" />

and so on.

My code for pagination is:

Code: Select all

<?php

                                        for($i = 1; $i <= $this->page_count; $i++)

                                        {

                                            if($i == $this->page_index)

                                            {

                                                echo '<li class="active"><a href="/category/'.$this->cat_url.'/'.$i.'">'.$i.'</a></li>';

                                            }else

                                            {

                                                echo '<li><a href="/category/'.$this->cat_url.'/'.$i.'">'.$i.'</a></li>';

                                            }

                                        }

                                    ?>
and the all code from my page that is from category is:

Code: Select all

<?php

 $this->headTitle()->append($this->pageTitle);

 $this->headMeta()->setName('keywords', $this->keywords);

 $this->headMeta()->setName('description', $this->description_2);

?>

<div class="about">

  <h2><?php echo $this->catName; ?></h2>

  <p><?php echo $this->description_1; ?></p>

  <!--<p><?php /*echo $this->description_2; */?></p>-->

</div>

<div class="cards">

  <ul>

<?php foreach($this->Products_array as $productId => $Product): ?>

    <li>
                        <div><img class="disquieter" src="../../images/rabatt_03.png" width="87" height="87">     </div>
                        <a href="<?php  echo $this->url(array('url' => $Product['product']['url']), 'products', true); ?>/"><img src="<?php echo $this->baseUrl("/assets/products/".$productId."/" . $Product['posters'][0]['smallThumbUrl']); ?>" width="263" height="213" alt="<?php echo $this->catName ?> - <?php echo $Product['product']['title']; ?>" title="<?php echo $this->catName ?> - <?php echo $Product['product']['title']; ?>"  /></a>

                        <h4><?php echo $Product['product']['title']; ?></h4>

                        <div class="variant">

                            <?php foreach($Product['posters'] as $key => $Poster): ?>

                                <div class="color" style="background-color:#<?php echo $Poster['color']; ?>;">&nbsp;</div>

                            <?php endforeach; ?>

                        </div>

                        <a href="<?php  echo $this->url(array('url' => $Product['product']['url']), 'products', true); ?>" class="show">Jetzt ansehen</a>

    </li>

<?php endforeach; ?>



                </ul>

                <ul class="pages">

                                    <?php

                                        for($i = 1; $i <= $this->page_count; $i++)

                                        {

                                            if($i == $this->page_index)

                                            {

                                                echo '<li class="active"><a href="/category/'.$this->cat_url.'/'.$i.'">'.$i.'</a></li>';

                                            }else

                                            {

                                                echo '<li><a href="/category/'.$this->cat_url.'/'.$i.'">'.$i.'</a></li>';

                                            }

                                        }

                                    ?>

                </ul>

            </div>

Re: Zend framework <link rel="next"> and <link rel="prev">"

Posted: Sat Oct 26, 2013 11:57 am
by requinix
Since you know the current page and you know the number of pages, you can fairly easily decide if there's a previous page (and which) and if there's a next page (and which). Then use the HeadLink helper.

This is assuming you're talking about prev/next links for that paginated stuff, which you posted code for, and not the article thing you actually made links out of.

Re: Zend framework <link rel="next"> and <link rel="prev">"

Posted: Sat Oct 26, 2013 12:41 pm
by roma2509
This is an attribute for google seo not a button for listing to next page or previous page

Re: Zend framework <link rel="next"> and <link rel="prev">"

Posted: Sat Oct 26, 2013 3:17 pm
by requinix
Right.

Re: Zend framework <link rel="next"> and <link rel="prev">"

Posted: Thu Jan 09, 2014 6:13 am
by superman7
This is assuming you're talking about prev/next links for that paginated stuff, which you posted code for, and not the article thing you actually made links out of.