Jump to content

PHP help for pagination...HELP!


Leah

Recommended Posts

Hi folks, 

 

you could help me with a PHP question. I changed our pagination from .../?page=0%2C0%2C1 to ?page=1.

 

The problem now is that a few custom codes aren't working anymore. There is one code that puts all following pages as nofollow/noindex. The code worked with the long pagination URL but not with the short. Here's the code:

 



<?php
$target_page= explode("/",$_SERVER['REQUEST_URI']);
$target_page= $target_page[1];

$pages_with_nofollow = array(
'nyc-apartments-by-school',
'park',
);

if(in_array($target_page, $pages_with_nofollow) ===true){
$target_page_num = isset($_GET['page']) ? explode(",",$_GET['page']) : 0;
$target_page_num = !empty($target_page_num) ? $target_page_num[2] : 0;
if($target_page_num > 0){
$variables['head'] .= '<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">';
}


}
?>


What do I need to change?

 

Thank you!!!

Link to comment
https://forums.phpfreaks.com/topic/284686-php-help-for-paginationhelp/
Share on other sites

For a quick hack, try changing this:

 

$target_page_num = !empty($target_page_num) ?  $target_page_num[2] : 0;

 

to this:

 

$target_page_num = !empty($target_page_num) ?  $target_page_num[0] : 0;

 

Not sure it's right, though --- YMMV and all that.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.