Zend framework Zend#u paginator不';当存在';我们需要一些参数

Zend framework Zend#u paginator不';当存在';我们需要一些参数,zend-framework,zend-paginator,Zend Framework,Zend Paginator,当我在结果的第一页时,它工作得非常好——我可以显示我需要的结果数量。 但是当我在另一个页面上时,结果的数量无法更改。为什么呢 例如,当我在3页上,每页显示12,我尝试将其更改为60,在链接的末尾,我有: perPage/12/submitPagin/Zastosuj/page/3?perPage=60&submitPagin=Zastosuj 有什么想法吗 my解析参数的函数: private function _parseSearchParams ( $params ) {

当我在结果的第一页时,它工作得非常好——我可以显示我需要的结果数量。 但是当我在另一个页面上时,结果的数量无法更改。为什么呢

例如,当我在3页上,每页显示12,我尝试将其更改为60,在链接的末尾,我有:

perPage/12/submitPagin/Zastosuj/page/3?perPage=60&submitPagin=Zastosuj
有什么想法吗

my解析参数的函数:

private function _parseSearchParams ( $params )
{
    if ( ! isset( $params[ 'perPage' ] ) ) {
        $params[ 'perPage' ] = 24;
    }

    foreach ( $params as $key => $value ) {
        if ( is_null( $value ) or $value == '' ) {
            unset( $params[ $key ] );
            continue;
        }


        switch ( $key ) {
            case 'tags':
            case 'im':
            case 'module':
            case 'submitupdate':
            case 'controller':
            case 'action':
            case 'submit':
                unset( $params[ $key ] );
                continue;
            break;

        }
    }

    return $params;
}
更改每页结果数的我的表单:

class ListIndexForm extends Zend_Form {
public function __construct($options = null) {
    parent::__construct ( $options );
    $this->setMethod ( 'GET' );


    $perPageValues = array(
        6    => 6,
        12    => 12,
        18    => 18,
        24   => 24,
        30   => 30,
        60   => 60,
        900  => 90,
        150  => 150,
        300  => 300,
        600 => 600,
    );
    $this->addElement ( 'Select', 'perPage', 
       array (
          'filters'           => array(
            'Digits'
          ),           
          'label'             => 'Obrazków na stronę',
          'MultiOptions'      => $perPageValues,
          'value'             => 24,
       )
    );

    $this->addElement ( 'Submit', 'submitPagin',
    array (
          'label' => 'Zastosuj',
      ) 
    );

}
}

view list.phtml:

(...)
<?=$this->searchForm;?>
<?foreach ($this->paginator as $row):?>
<?=$row['id']?>
<?enforeach;?>
<?= $this->paginationControl($this->paginator, 'Sliding', '../helpers/searchpagination.phtml', array( 'urlParams' => $this->params) ); ?>
(…)
searchpagination.phtml帮助程序:

    <?php
    $urlParams = isset($this->urlParams) ? $this->urlParams : array();
?>

<?php if ($this->pageCount): ?>
<div class="paginationControl">
<!-- Previous page link -->
<?php if (isset($this->previous)): ?>
<a href="<?= $this->url( array_merge( $urlParams, array('page' => $this->previous) ) ); ?>">
&lt; Nowsze
</a> |
<?php else: ?>
<span class="disabled">&lt; Nowsze </span> |
<?php endif; ?>

<!-- Numbered page links -->
<?php foreach ($this->pagesInRange as $page): ?>
<?php if ($page != $this->current): ?>
<a href="<?= $this->url( array_merge( $urlParams,  array('page' => $page))); ?>">
    <?= $page; ?>
</a> |
<?php else: ?>
<?= $page; ?> |
<?php endif; ?>
<?php endforeach; ?>

<!-- Next page link -->
<?php if (isset($this->next)): ?>
<a href="<?= $this->url( array_merge( $urlParams,  array('page' => $this->next)) ); ?>">
Starsze &gt;
</a>
<?php else: ?>
<span class="disabled">Starsze &gt;</span>
<?php endif; ?>
</div>
<?php endif; ?>

|
诺什|
|
|
斯塔斯

您似乎在两次指定perPage参数。(Zend Framework将两者都视为GET参数)

每页/12/submitPagin/Zastosuj/page/3?每页=60&submitPagin=Zastosuj


如果将第一个更改为60,会发生什么?我意识到这可能会导致您的URL结构出现问题。

在这种情况下,我的分页工作正常,从一个页面切换到另一个页面,结果不同。但我在该页面中有另一个链接,它调用其他操作,因此它将该操作与URL关联,使其正常工作,然后再次单击它我不知道为什么要这么做,但我还是不知道怎么做。
    <?php
    $urlParams = isset($this->urlParams) ? $this->urlParams : array();
?>

<?php if ($this->pageCount): ?>
<div class="paginationControl">
<!-- Previous page link -->
<?php if (isset($this->previous)): ?>
<a href="<?= $this->url( array_merge( $urlParams, array('page' => $this->previous) ) ); ?>">
&lt; Nowsze
</a> |
<?php else: ?>
<span class="disabled">&lt; Nowsze </span> |
<?php endif; ?>

<!-- Numbered page links -->
<?php foreach ($this->pagesInRange as $page): ?>
<?php if ($page != $this->current): ?>
<a href="<?= $this->url( array_merge( $urlParams,  array('page' => $page))); ?>">
    <?= $page; ?>
</a> |
<?php else: ?>
<?= $page; ?> |
<?php endif; ?>
<?php endforeach; ?>

<!-- Next page link -->
<?php if (isset($this->next)): ?>
<a href="<?= $this->url( array_merge( $urlParams,  array('page' => $this->next)) ); ?>">
Starsze &gt;
</a>
<?php else: ?>
<span class="disabled">Starsze &gt;</span>
<?php endif; ?>
</div>
<?php endif; ?>