2012-04-01 82 views
0

我想要路由到多個操作,我在application.ini文件上進行路由配置。路由到多個操作

resources.router.routes.blog.route = /blogs 
resources.router.routes.blog.defaults.module = blogs 
resources.router.routes.blog.defaults.controller = blog 
resources.router.routes.blog.defaults.action = index 


resources.router.routes.blog.route = /blogs/add 
resources.router.routes.blog.defaults.module = blogs 
resources.router.routes.blog.defaults.controller = blog 
resources.router.routes.blog.defaults.action = add 

當我做出這樣的,默認的路由/博客返回錯誤

Message: Invalid controller specified (index) 

array (
    'module' => 'blogs', 
    'controller' => 'index', 
    'action' => 'index', 
) 

回答

0

你的路由具有相同的名稱,調整你的路線,類似於:

//the 4th parameter is the name of the route and needs to be unique for each different route 
resources.router.routes.blogs.route = /blogs 
resources.router.routes.blogs.defaults.module = blogs 
resources.router.routes.blogs.defaults.controller = blog 
resources.router.routes.blogs.defaults.action = index 


resources.router.routes.blogsadd.route = /blogs/add 
resources.router.routes.blogsadd.defaults.module = blogs 
resources.router.routes.blogsadd.defaults.controller = blog 
resources.router.routes.blogsadd.defaults.action = add