具有自定义路由的 SocialEngine 模块
我正在为 SocialEngine 包开发一个模块,我希望能够指定多个自定义路由。
目前,我正在编辑模块目录中的 Bootstrap.php 文件,其中包含以下内容:
class Courses_Bootstrap extends Engine_Application_Bootstrap_Abstract
{
protected function _initRouter(){
$fc = Zend_Controller_Front::getInstance();
$router = $fc->getRouter();
$router->addRoute('courses', new Zend_Controller_Router_Route('courses/activity/:activity_id', array('module' => 'courses', 'controller' => 'index','action' => 'activity')));
$router->addRoute('courses', new Zend_Controller_Router_Route('courses/course/edit/:course_id', array('module' => 'courses', 'controller' => 'course','action' => 'edit')));
$router->addRoute('courses', new Zend_Controller_Router_Route('courses/course/create/:course_id', array('module' => 'courses', 'controller' => 'course','action' => 'create')));
return $router;
}
}
然而,当我指定多于 1 条路线时,所有路线都停止传递自定义变量(course_id 或 Activity_id),
我将按如下方式检索变量;
$course_id = $this->getRequest()->getParam("course_id");
我从这里采取了这种方法; http://tjgamble.com/2011/ 04/adding-custom-routes-to-your-socialengine-4-modules/
非常感谢,
安迪
I'm developing a module for the SocialEngine package and I'd like to be able to specify multiple custom routes.
Currently I'm editing the Bootstrap.php file found in the directory of my module with the following;
class Courses_Bootstrap extends Engine_Application_Bootstrap_Abstract
{
protected function _initRouter(){
$fc = Zend_Controller_Front::getInstance();
$router = $fc->getRouter();
$router->addRoute('courses', new Zend_Controller_Router_Route('courses/activity/:activity_id', array('module' => 'courses', 'controller' => 'index','action' => 'activity')));
$router->addRoute('courses', new Zend_Controller_Router_Route('courses/course/edit/:course_id', array('module' => 'courses', 'controller' => 'course','action' => 'edit')));
$router->addRoute('courses', new Zend_Controller_Router_Route('courses/course/create/:course_id', array('module' => 'courses', 'controller' => 'course','action' => 'create')));
return $router;
}
}
However it would seem that when I specify more then 1 route all routes stop passing in the custom variable (course_id or activity_id)
I'm retrieving the variable as follows;
$course_id = $this->getRequest()->getParam("course_id");
I've taken the approach from here;
http://tjgamble.com/2011/04/adding-custom-routes-to-your-socialengine-4-modules/
Many thanks,
Andy
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你必须给他们不同的名字:
you have to give them different names: