带 slug 和语言的 CakePHP 路由器
我试图在 CakePHP 中管理我的路线,但有点陷入困境。我阅读了 www 上的几乎每一篇文章,其中一些文章接近我需要的内容,但与其他文章结合起来却无法按预期工作。还尝试了一些路由器 lib-s,但相同
这就是我需要的:
url 中的语言参数和页面的 slug。所以:
前端
目录“/”应该指向默认语言,
controller
=>pages
,slug
=>;首页
/:lang - 与上面相同,但使用选定的语言
/:slug -
控制器
=>页面
,操作
=>index
并传递:slug
参数,使用默认语言/:lang/:slug - 与上面设置的 lang 参数相同
/:控制器/:slug -
/:lang/:controller/:slug - 与上面设置的 lang 参数相同
- 我不需要这些链接中的任何
操作
-s管理面板
/admin - '控制器' => '设置', '操作' => '索引'
/admin/:controller/:action/ ....这是默认的
- 管理网址中不需要语言参数,但操作存在,索引操作除外
另外我应该如何在视图内创建链接,以便路由器正常工作?
I am a bit in dead end trying to mane my routes in CakePHP. I read almost every article in the www and some of them close to what i need but combining with other dont work as expected. Also tried some router lib-s, but the same
Here is what I need:
Both language parameter in the url and a slug of the pages. So:
for the frontend
the directory '/' should lead to the default language,
controller
=>pages
,slug
=>home
/:lang - the same as above but with selected language
/:slug -
controller
=>pages
,action
=>index
and to pass the:slug
parameter, with default language/:lang/:slug - the same as above with set lang parameter
/:controller/:slug -
/:lang/:controller/:slug - the same as above with set lang parameter
- I dont need any
action
-s in those linksfor the admin panel
/admin - 'controller' => 'settings', 'action' => 'index'
/admin/:controller/:action/ .... this one is the default
- no need for language parameter in the admin url, but actions exists, except the index action
Also how should I create the links inside the view, so the routers to be working as the should?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以复制第二组路由,但将 :language 更改为 slug,您应该将其放在 if 中并验证给定的语言,如果未验证则加载 slug 路由。
You can copy past the second set of routes, but changing :language to slug, you should put it in an if and validate the language given, if it doesn't validate then load the slug routes.