PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Fri Jun 05, 2020 2:01 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Sat Oct 26, 2013 7:41 am 
Offline
Forum Newbie

Joined: Fri Sep 07, 2012 6:20 pm
Posts: 16
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:
Syntax: [ Download ] [ Hide ]
<?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:
Syntax: [ Download ] [ Hide ]
<?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>


Top
 Profile  
 
PostPosted: Sat Oct 26, 2013 11:57 am 
Offline
Spammer :|
User avatar

Joined: Wed Oct 15, 2008 2:35 am
Posts: 6617
Location: WA, USA
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 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.


Top
 Profile  
 
PostPosted: Sat Oct 26, 2013 12:41 pm 
Offline
Forum Newbie

Joined: Fri Sep 07, 2012 6:20 pm
Posts: 16
This is an attribute for google seo not a button for listing to next page or previous page


Top
 Profile  
 
PostPosted: Sat Oct 26, 2013 3:17 pm 
Offline
Spammer :|
User avatar

Joined: Wed Oct 15, 2008 2:35 am
Posts: 6617
Location: WA, USA
Right.


Top
 Profile  
 
PostPosted: Thu Jan 09, 2014 7:13 am 
Offline
Forum Newbie

Joined: Thu Jan 09, 2014 6:11 am
Posts: 1
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group