cakePHP 1.3 路由和命名参数
我有这种路由,用于在 cakePHP 1.2
Router::connect('/mycategory/my-region', array('controller'=>'search', 'action'=>'properties ''named'=>array('region'=>01)));
我怎样才能在 cake 1.3 中完成同样的任务,
谢谢
I had this kind of routes that used to work on cakePHP 1.2
Router::connect('/mycategory/my-region', array('controller'=>'search', 'action'=>'properties''named'=>array('region'=>01)));
How can I accomplish the same in cake 1.3
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果
my-region
始终等于01
,那么您的解决方案与我猜测的任何其他解决方案一样好。但是,如果您希望能够拥有多个不同的区域,那么我建议采用以下路线:这样您就可以在控制器中获取
my-region
的值,如下所示:控制器部分可以通过 if/switch 语句得到很大的改进。只是想举一个非常基本的例子。
编辑:然后,像这样构建链接:
它应该自动输出:
我的区域
If
my-region
always equals to01
, then your solution is as good as any other I guess. If however you'd like to be able to have several different regions, then I would suggest something like the following route:And so you can get the value of
my-region
in your controller like so:The controller part can be greatly improved, with if/switch statements. Just wanted to give a very basic example.
Edit: And then, build your links like so:
which should automagically output:
<a href="/mycategory/my-region">My Region</a>