2015-10-26 66 views
0

这里是我的配置我cortana-resources路线:添加子路由到Zend框架模块控制器

  'cortana-resources' => array(
       'type' => 'Zend\Mvc\Router\Http\Literal', 
       'options' => array(
        'route' => '/cortana/resources', 
        'defaults' => array(
         'controller' => 'Cortana\Controller\Resources', 
         'action'  => 'index', 
        ), 
       ), 
       'may_terminate' => true, 
       'child_routes' => array(
        'default' => array(
         'type' => 'Segment', 
         'options' => array(
          'route' => '/[:controller[/:action]]', 
          'constraints' => array(
           'controller' => '[a-zA-Z][a-zA-Z0-9_-]*', 
           'action'  => '[a-zA-Z][a-zA-Z0-9_-]*', 
          ), 
          'defaults' => array(
          ), 
         ), 
        ), 
       ), 
      ), 

cortana-resources路由用于整个系统的参考http://127.0.0.1/cortana/public/cortana/resources

我想补充的一个add actionresources controller下的Cortana模块。我该如何做到这一点?它没有正确解决。

+0

你想要什么URL,你目前得到什么错误?你目前的路由配置是'/ cortana/resources// /',这听起来不像你想要的那样。 –

+0

我想''cortana/resources/add'引用'cortana'模块中的'ResourcesController'和'add'动作 – jkushner

回答

0

基于您的评论,我建议你只需要改变你的路线配置到这一点:

'cortana-resources' => array(
    'type' => 'Zend\Mvc\Router\Http\Segment', 
    'options' => array(
     'route' => '/cortana/resources[/:action]', 
     'defaults' => array(
      'controller' => 'Cortana\Controller\Resources', 
      'action'  => 'index', 
     ), 
    ), 

除非你想添加这个路线如下其它控制器,还有在这里使用童工的路线没有真正的理由。