【问题标题】:Remove particular query string from url in cakephp 3.x从 cakephp 3.x 中的 url 中删除特定的查询字符串
【发布时间】:2017-03-20 09:30:54
【问题描述】:

我知道我的问题标题听起来像是重复的,但事实并非如此。我们的项目是多语言的。我在此页面上有列表页面 cakephp 分页已应用。但是页码的链接是:

http://example.com/controller/action?language=en&page=8

我已经实现了路由消失动作,使用下面提到的路由代码:

$routes->connect('/controller', 
               ['language' => 'en', 'controller' => 'controller', 'action' => 'action']
    );

所以现在是:

http://example.com/controller?language=en&page=8

但我的要求是这样的

http://example.com/controller?page=8

为了实现我的目标,我实现了这段代码

$routes->connect('/controller/:page', 
           ['language' => 'en', 'controller' => 'controller', 'action' => 'action'], ['page' => "(?page:'[0-9]+]')"]
);

提前致谢。

【问题讨论】:

  • 我也需要同样的东西...

标签: php cakephp routing cakephp-3.x


【解决方案1】:

您可能需要调整 PaginatorHelper 设置以将 language 参数传递给其链接。

$this->Paginator->options([
    'url' => [
        'language' => 'en'
    ]
]);

https://book.cakephp.org/3.0/en/views/helpers/paginator.html#configuring-pagination-options

【讨论】:

    猜你喜欢
    • 2016-10-25
    • 1970-01-01
    • 2011-02-02
    • 1970-01-01
    • 2011-02-26
    • 2016-07-22
    • 2011-03-28
    相关资源
    最近更新 更多