cakephp 从Cake PHP 2分页器生成的链接中禁用URL查询选项

iyzzxitl  于 2022-11-11  发布在  PHP
关注(0)|答案(1)|浏览(118)

我正在使用Cake PHP 2分页在我的视图中生成链接。我所在的页面URL是:

当我想在我的页面中向前导航时,Cake添加了一个url编码值,表示我当前的页面路径:payday_admin/leads到我的URL,沿着limit选项。这两个我都不需要,我只需要page号码。
如何禁用此功能?
它看起来是这样的:

下面是我的视图标记:

<nav aria-label="Page navigation example">
  <ul class="pagination justify-content-end mb-0">
    <?php
      echo $this->Paginator->prev('Prev', array('tag' => 'li', 'class'=>'page-item', ' class'=>'page-link'), null, array('class' => 'disabled page-item', 'tag' => 'li', 'disabledTag' => 'a', ' class' =>'page-link'));
      echo $this->Paginator->numbers(array('separator' => '', 'currentTag' => 'a', 'tag' => 'li', 'class'=>'page-item', 'currentClass' => 'disabled bg-primary text-white page-link', ' class'=>'page-link','modulus'=>6));
      echo $this->Paginator->next('Next', array('tag' => 'li', 'class'=>'page-item', ' class'=>'page-link'), null, array('class' => 'disabled page-item', 'tag' => 'li', 'disabledTag' => 'a', 'currentClass'=>'page-link', ' class' =>'page-link'));
    ?>
  </ul>
</nav>

我的控制器...

// define pagination settings
$this->Paginator->settings = array(
        'Application' => array(
                'paramType' => 'querystring',
                'totalLimit' => 20000,
                'limit' => 20000,
                'maxLimit' => $filters['pagination']['perPage'],
                'fields' => array(
                        'Application.*',
                        'ApplicationPayday.*',
                        'ApplicationApiLink.*',
                        'ApplicationResponse.*',
                        'AffiliateId.*',
                        'Redirect.*'
                ),
                'joins' => array(
                        array(
                                'table' => 'tlp_application_paydays',
                                'alias' => 'ApplicationPayday',
                                'type' => 'LEFT',
                                'conditions' => array(
                                        'ApplicationPayday.application_id = Application.id'
                                )
                        ),
                        array(
                                'table' => 'tlp_application_api_links',
                                'alias' => 'ApplicationApiLink',
                                'type' => 'LEFT',
                                'conditions' => array(
                                        'ApplicationApiLink.application_id = Application.id'
                                )
                        ),
                        array(
                                'table' => 'tlp_application_responses',
                                'alias' => 'ApplicationResponse',
                                'type' => 'LEFT',
                                'conditions' => array(
                                        'ApplicationResponse.application_id = Application.id'
                                )
                        ),
                        array(
                                'table' => 'tlp_affiliate_ids',
                                'alias' => 'AffiliateId',
                                'type' => 'LEFT',
                                'conditions' => array(
                                        'AffiliateId.aff_id = Application.tlp_aff_id'
                                )
                        ),
                        array(
                                'table' => 'tlp_redirects',
                                'alias' => 'Redirect',
                                'type' => 'LEFT',
                                'conditions' => array(
                                        'Redirect.application_id = Application.id'
                                )
                        )
                ),
                'conditions' => array(
                        'Application.modified_timestamp >=' => $initialStartDate,
                        'Application.modified_timestamp <=' => $initialEndDate
                ),
                'group' => array(
                        'Application.id'
                ),
                'order' => array(
                        'Application.id' => 'desc'
                ),
                'recursive' => -1
        )
);

// run query to get applications via paginated settings
$applications = $this->Paginator->paginate('Application');

我只需要:

ie3xauqp

ie3xauqp1#

添加参数是因为Paginator设置中的'paramType' =〉'querystring'。如果您删除它并手动创建路由,请使用如下命名参数:

Router::connect(
        '/payday_admin/leads/page::page',
        ['controller' => 'payday_admin', 'action' => 'leads', 'full_path' => '/payday_admin/leads'],
        ['page' => '[0-9]+', 'filter_string' => '[a-z0-9;=\-,\/]+',]
);

您的URL将更干净:
/payday_admin/潜在客户/页面:1,/payday_admin/潜在客户/页面:2

相关问题