编辑后重定向正确的分页索引页面

问题描述 投票:0回答:3

我正在尝试编辑(edit.cto)第2页,但在编辑后它总是重定向到索引页面1.我如何重定向右分页?

预期 - > https://localhost/erp-development/EmployeeMonthlySalaries/index/page:2

得到 - > https://localhost/erp-development/EmployeeMonthlySalaries/index/

cakephp cakephp-2.0 cakephp-2.3
3个回答
0
投票

你可以使用session来做到这一点。

例如,在索引控制器集中:

$this->request->session()->write('referer', ($_SERVER['REQUEST_URI'])); //cakephp 3

$this->Session->write('referer', ($_SERVER['REQUEST_URI'])); //cakephp 2

然后在编辑控制器:

return $this->redirect($this->request->session()->read('referer')); //cakephp 3

return $this->redirect($this->Session->read('referer')); //cakephp 2

0
投票

首先,我建议不要使用命名参数,因为它们只是CakePHP功能而不是标准功能。我建议使用常规GET参数:

'Paginator' => array(
    'limit' => 15,
    'paramType' => 'querystring'
),

在您的组件定义中。

然后,我将使用自定义的makeUrl()函数构建所有URL,或者覆盖HtmlHelper :: link(),以便它们都包含收到的查询字符串。您的编辑操作将具有URL:/ controller / edit /?page = 2,您编辑操作将知道如何构建重定向URL /控制器/索引?page = 2


0
投票

您只需将以下重定向代码替换为在控制器中编写重定向代码:

<?php $this->redirect($this->referer()); ?>
© www.soinside.com 2019 - 2024. All rights reserved.