【发布时间】:2012-04-20 21:58:56
【问题描述】:
我有一个来自控制器的操作,它通过$this->set('found_products', $data); 提供结果变量。查看页面products.ctp分为两部分:
在顶部,为视图设置了一个用户输入字符串以搜索
$found_products的表单。在其下方,仅当设置了
$found_products时才会显示分页结果。即if (isset($found_products))为真。
当if (isset($found_products)) 为真时,我会在表单下方显示第一页,其中搜索字符串已经在文本框中。这个网址是myapp/controller/products。
当我进入下一页时出现问题。 URL 变为myapp/controller/action/products:2,并且myapp/controller/products 下使用的变量都不存在。看起来移动到新页面会清除所有变量。下面是我用于分页的代码,我没有为此编写重新路由规则。我该如何解决这个问题?
<div class="paging">
<?php echo $this->Paginator->prev('<< ' . __('previous', true), array(), null, array('class'=>'disabled'));?>
<?php echo $this->Paginator->numbers();?>
<?php echo $this->Paginator->next(__('next', true) . ' >>', array(), null, array('class' => 'disabled'));?>
</div>
我尝试在操作 (products) 中使用 $_SESSION 解决此问题,并将其设置为视图,但是当我这样做时,`$this->Paginator' 不再起作用。
【问题讨论】: