Zend framework2 zf2$此url具有动态路由
我在module.config.php中有以下路由Zend framework2 zf2$此url具有动态路由,zend-framework2,Zend Framework2,我在module.config.php中有以下路由 'router' => array( 'routes' => array( 'home' => array( 'type' => 'Zend\Mvc\Router\Http\Literal', 'options' => array( 'route' => '/'
'router' => array(
'routes' => array(
'home' => array(
'type' => 'Zend\Mvc\Router\Http\Literal',
'options' => array(
'route' => '/',
'defaults' => array(
'controller' => 'Application\Controller\Index',
'action' => 'index',
),
),
),
// The following is a route to simplify getting started creating
// new controllers and actions without needing to create a new
// module. Simply drop new controllers in, and you can access them
// using the path /application/:controller/:action
'application' => array(
'type' => 'Literal',
'options' => array(
'route' => '/application',
'defaults' => array(
'__NAMESPACE__' => 'Application\Controller',
'controller' => 'Index',
'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(
),
),
),
),
),
),
),
我的Layout.phtml文件中有以下URL
<li class="active"><a href="<?php echo $this->url('home') ?>"><?php echo $this->translate('Home') ?></a></li>
<li class="active"><a href="<?php echo $this->url('application',array('controller'=> 'mycontrollername', 'action'=>'index')) ?>"><?php echo $this->translate('My URL') ?></a></li>
主链接工作正常,对于第二个动态链接,它应该是这样的<代码>
但相反,它正在产生这一点
有什么想法吗
我已经检查了以下链接,但这些都没有帮助我解决这个问题。我更喜欢使用URl帮助程序,而不是硬编码
怎么回事!?为什么要在模块名前面加上默认值才能让它工作呢?哦,现在我明白了。这是一条命名路线,对吗?我可以有很多不同的名字,映射到不同的东西?见鬼!?为什么要在模块名前面加上默认值才能让它工作呢?哦,现在我明白了。这是一条命名路线,对吗?我可以有很多不同的名字映射到不同的东西?
<?php echo $this->url ('application/default', array ('controller' => 'xxx', 'action' => 'x')); ?>