You are here:  » External.php - Pagination Not Working As Before?


External.php - Pagination Not Working As Before?

Submitted by Stew on Sun, 2014-02-23 12:49 in

Hi there, hope all's well.

We're using external.php and all of a sudden our pagination isn't working, the page numbers are displaying at the bottom of the search results, but if you click on page 2 for example, the url changes and the browser goes to the url, but the results haven't updated and are the same as page 1.

Any ideas?

Submitted by support on Mon, 2014-02-24 08:19

Hello Stew,

I just looked up the last version I have a copy of in email conversation with you and the pagination should be picked up by this code at line 145:

  $page = (isset($_GET["page"])?$_GET["page"]:1);

Double check that is in place and correspondingly the following code beginning at line 514:

    $offset = ($page-1) * $config_resultsPerPage;
    $sql .= " LIMIT ".$offset.",".$config_resultsPerPage;

If that's all in place, can you confirm that when choosing page 2 from the navigation, are you seeing "&page=2" within the new URL? Also if it's convenient to include a link to the page using calling external.php with example results showing the navigation that will help (I'll remove the URL before publishing your reply) and I'll check it out further for you...

Cheers,
David.
--
PriceTapestry.com

Submitted by Stew on Tue, 2014-02-25 18:51

Hi David,

Many thanks for the reply, in external.php we can see:

$page = (isset($_GET["page"])?$_GET["page"]:1);

in place on line 287, and:

$offset = ($page-1) * $config_resultsPerPage;
$sql .= " LIMIT ".$offset.",".$config_resultsPerPage;

on line 914.

When selecting page 2 we see:

{link saved}

where page 1 is:

{link saved}

The weird thing is this has worked historically - not sure what could of changed here?

Many Thanks

Submitted by support on Wed, 2014-02-26 07:50

Thanks for the links Stew, I see that there is actually a rewrite going on, so whilst the next page links generate URLs of, for example ?q=keywords&page=2 this is being re-written into /2/?q=keywords so I suspect that something has changed in .htaccess so that although having rewritten the page to /2/ it is no longer propagating the value 2 in $_GET["page"] - that should be all it is.

If you're not sure, if you'd like to post your .htaccess i'll take a look for you of course...

Cheers,
David.
--
PriceTapestry.com

Submitted by Stew on Wed, 2014-02-26 09:38

Hi David, many thanks for looking at this, it's strange looking at the datestamp .htaccess was changed 6 months ago - but have no idea why!

Here is the .htaccess output:

SetEnv PHPRC "/home/wwwvibr/public_html"
# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

Thanks,

Submitted by support on Wed, 2014-02-26 10:58

Hi Stew,

That's the stock WordPress .htaccess so it's probably happening internally, and I think it's a conflict with the page= variable, so probably the best thing to do is change the page variable name used by external.php, which is easy to do.

Make a back-up of each of the files of course so that it's easy to roll back if necessary, and then in external.php look for the following code at line 145:

  $page = (isset($_GET["page"])?$_GET["page"]:1);

...and REPLACE with:

  $page = (isset($_GET["externalpage"])?$_GET["externalpage"]:1);

And then the following code at line 608:

  require($external_path."html/navigation.php");

...and REPLACE with:

  require($external_path."html/externalnavigation.php");

Next, in the associated Price Tapestry installation, make a copy of html/navigation.php and save as html/externalnavigation.php. Finally, edit the new version and do a Search and Replace as follows:

Search:

page=

Replace:

externalpage=

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by Stew on Wed, 2014-02-26 13:23

Hi David, just went through both files and changed as above and worked first time! fantastic!

Many thanks for that,