duai5344 2011-11-29 17:05
浏览 28

CakePHP分页(最后一次参考剪辑)

I have a "little" problem with the Pagination system of CakePHP (1.2). Here is the query:

$this->paginate = array (
    'fields'     => array (
       'Content.slug',
       'Content.title',
       'Content.resume',
       'Content.format',
       'Content.image',
       'Content.video',
       'Criteria.name'
    ),
    'conditions' => $conditions,
    'order'      => 'Content.created DESC',
    'limit'      => 10,
    'contain'    => array (
        'Category',
        'Criteria',
    )
);

$this->set("PRODUCTS", $this->Paginate("Content"));

And the code of view:

<?php $total_pages  = (int)$paginator->counter(array('format' => '%pages%')); ?>
<?php if($total_pages > 1){ ?>
<div class="paginar">
    <div class="next_pre_arrow">
        <?=$paginator->prev("Anterior", array("class" => "pre", "escape" => false))?>
        <?=$paginator->next("Siguiente", array("class" => "next", "escape" => false))?>
        <div class="pages">
            <span>Página</span> <?=$paginator->numbers(array('separator' => ' | '))?> 
        </div>
    </div>
</div>
<?php } ?>

What is the problem? The pagination works OK but with a little problem. In the "next" and "prev" buttons, and in the page numbers, the URL is truncated, deleting the last param, for example:

"http://www.domain.com/controller-name/caction-name/option-1/option-2"

Show paging links with this URL:

"http://www.domain.com/controller-name/caction-name/option-1/page:2"

NOT the correct:

"http://www.domain.com/controller-name/caction-name/option-1/option-2/page:2"

What is the cause of this?

  • 写回答

1条回答 默认 最新

  • drl971115 2011-11-29 17:32
    关注

    I think you can customize the links that are generated by the Paginator helper using the options() method.

    Specifically, you can use $options['url'] to pass a custom URL, as if you were setting parameters of a link() call:

    $paginator->options(array(
      'url' => array(
        'controller' => 'YourController',
        'action' => 'your_action'
        'param1' => 'value_1',
        'param2' => 'value_2',
    )));
    
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?