AVS pagination and SEO tips Part 2

December 5, 2014 at 1:12 am

In first part of AVS v.3 script Tips I described and posted code example improving “Videos” section for better SEO practice.
In second part you will learn code you need to do same but for “Photos” section. The code is very similar, you only do not need to alter template “header” file.

Just edit file “albums.php”
Above line:

$smarty->assign('errors',$errors);

Add this code:

if(isset($_GET['page'])) { 
   if (intval($_GET['page'])>1) {
      $self_title.= ". Page - ".intval($_GET['page']); 
      $self_description = "Page - ". intval($_GET['page']). ". ".$self_description;
   }
}

$canonical = $config['BASE_URL'].'/albums';
if(strlen($_SERVER['QUERY_STRING'])>0) $canonical.='?'.$_SERVER['QUERY_STRING'];
if($start_num<$end_num) {
	$next=2;
	if(isset($_GET['page'])) { $cpage=intval($_GET['page']); $next=$cpage+1; }
	if(isset($cpage)) {
		$relnext =  str_replace('page='.$cpage,'page='.$next,$canonical);
	} else {
		if(strlen($_SERVER['QUERY_STRING'])>0) $relnext = $canonical."&page=".$next; else $relnext = $canonical."?page=".$next;
	}
	$smarty->assign('relnext',$relnext);
}
if(isset($_GET['page'])) {
	$cpage=intval($_GET['page']);
	if($cpage>1) {
		$relprev =  str_replace('page='.$cpage,'page='.($cpage-1),$canonical);
	}
	$smarty->assign('relprev',$relprev);
}
$smarty->assign('canonical',$canonical);

This is all.
Now you should have rel “canonical”, rel “prev” and rel “next” links in your header. Additinally number of page will be added to meta title and description for each albums page.