Zend framework <link rel="next"> and <link rel="prev">"
Posted: Sat Oct 26, 2013 7:41 am
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:
and the all code from my page that is from category is:
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>';
}
}
?>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']; ?>;"> </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>