PDA

View Full Version : changing base URLs for filtered and peagenated results


stephen101
11-08-08, 18:29
Hi
I am trying to figure out where I can change the base URLs for calling filtered and pagenated results from the productlist page.
As far as I can see, when a 'product list' set of results is produced, the URLs for moving to page 2, 3, 4 etc of the results is done by appending something like
?q=table&iListOffset=20
to whatever the 'current page' is

Is there a way I can specify the URL of the 'current page'.

Thanks in advance

stephen101
11-08-08, 18:58
Update...
I figured out that the pagenation one can be set in
nav_product_list.php
by changing
$sCurrentPage = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'];
to
$sCurrentPage = 'http://mysite.com/choseurl.php';

Anybody know where I can do the same for the filtered results?

Andy
13-08-08, 17:30
If I've read you question correctly, you are trying to get the current page url.
Here's a very useful function you can use for that.


function curPageURL() {
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
}
Doesn't matter what your page url consists of, it'll return the full address from http: onwards. Add to a seperate file and "require_once()" in global.inc.php

now, if you just want the actual page number, as is defined in the pagination.......


$pageNumber = $_GET['iListOffset'];
will suffice as your variable, however I'd be more inclined to give it some validation with:

$pageNumber = (isset($_GET['iListOffset']) ? htmlspecialchars(stripslashes($_REQUEST['iListOffset'])) : '');

if(!is_numeric($pageNumber)){
$pageNumber = '';
}



Hows that?

stephen101
21-08-08, 12:45
Hey Andy
Thanks so much for taking the time to post. Been away and not had a chance to log in.
The scripts and advice are really helpful
Thanks !
Stephen