【发布时间】:2011-07-31 20:34:46
【问题描述】:
嗨,CakePHP 大师!我想问一些事情。
我觉得problem很简单,是否可以像这样在cakephp应用程序中生成一个url? (这是类似 url 的谷歌邮件 - http://mail.google.com/a/domain.com)
http://www.domain.com/a/[something]/[member]/[controller]/[action]
其中 [something] 是动态变量,[member] 是前缀,[controller] 和 [action] 通常是 cakephp url 元素。
所以我想将通常的 CakePHP url 向右移动,或者在初始 url 中插入 /a/something/。 另外,应该从控制器动作中读取[something]
谢谢,您的帮助对我来说非常有价值,并且会真正帮助我
问题 v2: 我试图将此路由添加到 routes.php
Router::connect('/:code/:something/:controller/:action',
array(),
array('code'=>'a','pass'=>array('something'))
);
当我尝试访问http://domain.local/a/pte/users/view 时,它可以工作,但是当我尝试访问http://domain.local/a/pte/users 时它显示错误
问题 v3:
所以简单的问题是:
如何在不破坏 默认 CakePHP 路由?
QUESTION v4:(感谢@Rui)
我尝试创建此路由:
Router::connect('/:code/:something/:prefix/:controller/*',
array(),
array('code'=>'a','pass'=>array('something'))
);
我尝试访问时没问题
http://domain.local/a/pte/member/users(结果是 cake render member_index 视图,进步很大:-)),
但有几个问题:
- 当我尝试访问
http://domain.local/a/pte/users(没有前缀成员,我决定显示索引函数)失败(显示错误 AController 未定义) -
当我创建一个链接时
echo $html->link('test link',array('code'=>'a','something'=>'pte','member'=>true,'controller'=>'users' ,'action'=>'another_view'));
它会生成这样的链接
http://domain.local/member/users/another_view/code:a/something:pte
【问题讨论】: