Home > Archive > PHP Pear > January 2005 > Re: [PEAR] Pager and Cookies
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Re: [PEAR] Pager and Cookies
|
|
| Lorenzo Alberton 2005-01-26, 8:56 pm |
| Hi,
Andrew Nagy wrote:
> I am implementing cookies with my paged application so that I can come
> back to the list without loosing my place. Basically the page number is
> stored in the cookie. However I am experiencing some strange results.
>
> My application is working fine as I page through the results, however
> the list of pages is showing that I am on the previous page (obviously
> because I have a cookie with the same name as the page variable).
>
> Is their a way that I can specify the page I am on instead of pager
> determining this for me with the $_REQUEST variable, or can the pager
> code be modified as to not use the $_REQUEST variable but to use the
> following if statement?
>
> if (isset($_POST[$pageId])) {
> ...
> } elseif (isset($_GET[$pageId])) {
> ...
> } elseif (isset($_COOKIE[$pageId])) {
> ...
> }
if you have the latest release, you can
set the current page number with the
'currentPage' option:
$options = array(
'mode' => 'Sliding',
'perPage' => 3,
'delta' => 2,
'itemData' => array('a','b','c','d','e',),
'currentPage' => $_COOKIE[$pageId],
);
$pager =& Pager::factory($options);
HTH
--
Lorenzo Alberton
http://pear.php.net/user/quipo
| |
| Andrew Nagy 2005-01-27, 4:00 pm |
| Lorenzo Alberton wrote:
>
> if you have the latest release, you can
> set the current page number with the
> 'currentPage' option:
Thanks, but it still doesn't seem to work because I have a different
page variable, so I would still like to use the 'urlVar' option as well.
Any ideas?
Andrew
| |
| Andrew Nagy 2005-01-27, 4:00 pm |
| Andrew Nagy wrote:
> Lorenzo Alberton wrote:
>
> Thanks, but it still doesn't seem to work because I have a different
> page variable, so I would still like to use the 'urlVar' option as well.
>
> Any ideas?
>
> Andrew
Maybe something like this:
Line 1128:
if (isset($_REQUEST[$this->_urlVar]) && !isset($options['currentPage'])) {
$this->_currentPage = (int)$_REQUEST[$this->_urlVar];
}
| |
| Andrew Nagy 2005-01-27, 4:00 pm |
| Andrew Nagy wrote:
> Andrew Nagy wrote:
>
>
>
>
> Maybe something like this:
>
> Line 1128:
> if (isset($_REQUEST[$this->_urlVar]) && !isset($options['currentPage'])) {
> $this->_currentPage = (int)$_REQUEST[$this->_urlVar];
> }
Better yet:
if (isset($_REQUEST[$this->_urlVar]) &&
$options['currentPage'] !== null)) {
| |
| Andrew Nagy 2005-01-27, 8:57 pm |
| Andrew Nagy wrote:
> Andrew Nagy wrote:
>
well.[color=darkred]
>
>
> Better yet:
> if (isset($_REQUEST[$this->_urlVar]) &&
> $options['currentPage'] !== null)) {
Long day, here is my diff that I have test and seems to work great
RCS file: /repository/pear/Pager/Common.php,v
retrieving revision 1.29
diff -r1.29 Common.php
1128c1128
< if (isset($_REQUEST[$this->_urlVar])) {
---
> if (isset($_REQUEST[$this->_urlVar]) &&
($options['currentPage'] === null)) {
| |
| Lorenzo Alberton 2005-01-27, 8:57 pm |
| Hi Andrew,
Andrew Nagy wrote:
> Long day, here is my diff that I have test and seems to work great
Phew, how many mails :-D
> RCS file: /repository/pear/Pager/Common.php,v
> retrieving revision 1.29
> diff -r1.29 Common.php
> 1128c1128
> < if (isset($_REQUEST[$this->_urlVar])) {
> ---
> ($options['currentPage'] === null)) {
committed, thanks!
Regards,
--
Lorenzo Alberton
http://pear.php.net/user/quipo
|
|
|
|
|