PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » HTML » Pager » Bug #4934

Bad page number

Details

Request #4934Bad page number
Submitted2005-07-28 12:01 UTC
Fromfekete_a at freemail dot hu
Assignedquipo
StatusBogus
PackagePager
PHP Version4.3.11
OSSuSE 9.2
Roadmaps(Not assigned)

Comments

[2005-07-28 12:01 UTC] fekete_a at freemail dot hu

Description:
------------
Sorry for my bad English:)
See the script!
I think it should have to display 1,2,3,4
but it shows only 1.
8 item, 2/page. I think it's 4 page...

Test script:
---------------
for ($i=0; $i < 8; $i++) {
$myData[] = $i;
}
$params = array(
'itemData' => $myData,
'perPage' => 2,
'delta' => 8, // for 'Jumping'-style a lower number is better
'append' => true,
'separator' => '-',
'clearIfVoid' => false,
'urlVar' => 'entrant',
'useSessions' => true,
'closeSession' => true,
//'mode' => 'Sliding', //try switching modes
'mode' => 'Jumping',

);
$pager = & Pager::factory($params);

[2005-07-28 12:14 UTC] fekete_a at freemail dot hu

I use Smarty, so:
{$links.all} ( or not in Smarty $links['all'] must have to show what you wrote, but it don't...:(

[2005-07-28 12:20 UTC] fekete_a at freemail dot hu

Ok. I can use Smarty...
{$links} is an array, like Smarty says.
We have to use {$links.all} to show everything.

The biggest problem (I think) this:
pager_sliding Object
(
[_totalItems] => 8
[_perPage] => 10
[_delta] => 8
...
)
I write
$params = array(
'itemData' => $myData,
'perPage' => 2,
'delta' => 8,
...
)

So why? perPage = 10 ??? why?
I said perPage=2 !!!

[2005-07-28 12:30 UTC] fekete_a at freemail dot hu

OK! GO!
This is the php:
$myData = array();
for ($i=0; $i < 8; $i++) {
$myData[] = $i;
}
$params = array(
'itemData' => $myData,
'perPage' => 10,
'delta' => 8, // for 'Jumping'-style a lower number is better
'append' => true,
'separator' => '-',
'clearIfVoid' => false,
'urlVar' => 'entrant',
'useSessions' => true,
'closeSession' => true,
'mode' => 'Sliding', //try switching modes
//'mode' => 'Jumping',

);
$pager = & Pager::factory($params);
$page_data = $pager->getPageData();
$links = $pager->getLinks();
$smarty->assign('links',$links);

This is the tpl:
<center>{$links.all}</center>

Thx for you help

[2005-07-28 12:31 UTC] fekete_a at freemail dot hu

Sorry! replace perpage 10 to 2...

[2005-07-28 12:51 UTC] fekete_a at freemail dot hu

Ok. I understand everything...
But why makes it wrong?
If a make a bigger array (200)
and perPage=10, it works, but I don't want to use 200 item in my array.
Do you understand?
So {$links} make this output: Array
{$links.all} make this output: 1 , but
it should have to display <<back 1,2,3,4 ...>>

So I don't understand why ...

[2005-07-28 13:01 UTC] fekete_a at freemail dot hu

Please don't be angry at me! I'm not professional.
I tried your code:
The result:
array(14) {
[0]=>
string(0) ""
[1]=>
string(33) "1 "
[2]=>
string(0) ""
[3]=>
string(0) ""
[4]=>
string(0) ""
[5]=>
string(33) "1 "
[6]=>
string(0) ""
["back"]=>
string(0) ""
["pages"]=>
string(33) "1 "
["next"]=>
string(0) ""
["first"]=>
string(0) ""
["last"]=>
string(0) ""
["all"]=>
string(33) "1 "
["linktags"]=>
string(0) ""
}

I think it's not a Smarty-problem...

[2005-07-28 13:19 UTC] fekete_a at freemail dot hu

I can't believe this!!!
$params = array(
'itemData' => $myData,
'perPage' => 2,
'delta' => 8, // for 'Jumping'-style a lower number is better
'append' => true,
'separator' => '-',
'clearIfVoid' => false,
'urlVar' => 'entrant',
'useSessions' => true,
'closeSession' => true,
'mode' => 'Sliding', //try switching modes
//'mode' => 'Jumping',

);
My result:
int(8)
int(8)
int(10)

How???

[2005-07-28 14:03 UTC] fekete_a at freemail dot hu

did you receive?

[2005-07-28 14:39 UTC] fekete_a at freemail dot hu

No!

I change it conutinuously...
Try with 2. Don't work!!!

It's always 10!!!
$params = array(
'itemData' => $myData,
'perPage' => 5,
...)

var_dump(count($myData)); //array size
var_dump($pager->_totalItems); //idem
var_dump($pager->_perPage); //items per page, should be == to

result:
int(15)
int(15)
int(10)
I tried 2, 5, 8, 10, 1000, everything!!!

[2005-07-28 14:44 UTC] fekete_a at freemail dot hu

Whááááááááááá!
The 10 was in session!!!
And that was the problem.
I use firefox and i use letters with it's top.
And was a letter with the pager example.php and there is a selectbox which generate a GET variable and send it to session.
That's why I always had 10...
Thx for your help and sorry for ... everything!:D