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

Discussion for various published PHP frameworks, including Zend Framework, CodeIgniter, Kohana, CakePHP, Yii, Symfony, and others.

Moderator: General Moderators

Post Reply
roma2509
Forum Newbie
Posts: 16
Joined: Fri Sep 07, 2012 6:20 pm

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

Post 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>
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

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

Post 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.
roma2509
Forum Newbie
Posts: 16
Joined: Fri Sep 07, 2012 6:20 pm

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

Post by roma2509 »

This is an attribute for google seo not a button for listing to next page or previous page
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

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

Post by requinix »

Right.
superman7
Forum Newbie
Posts: 1
Joined: Thu Jan 09, 2014 5:11 am

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

Post 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.
Post Reply