【发布时间】:2013-05-19 00:21:56
【问题描述】:
我在我的一个项目中使用 CakePHP。当我在设计 URL 时,我知道 CakePHP 在我使用时做得很好
$this->Html->Link('Add Post', array('controller'=>'posts', 'action'=>'edit', 1234))
CakePHP 将生成 URI /appname/posts/edit/1234。但是我在想 /appname/post/1234/edit 比前者更好。我找不到解决方法。
我试过了
$this->Html->Link('Add Post', array('controller'=>'posts', 1234, 'action'=>'edit'))
但是 CakePHP 会忽略数组的顺序。
有谁知道如何实现这个网址?基本上我不想修改函数Router::url,我需要在我的ctp视图文件和CakePHP中编写代码来知道我放的正确顺序。我该怎么做?
顺便说一句,我使用的是 CakePHP 2.3。
【问题讨论】:
-
您需要实际使用路由 -
Config/routes.php。网上的 CakePHP 书中有很多例子。
标签: cakephp cakephp-2.3