이-URL은 내 module.config.php
'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>
홈 링크가 잘 작동하고 있습니다. 두 번째 동적 인 경우 홈 링크가 잘 돌아갑니다. <a href="/application/mycontrollername/index">My URL</a>
그러나 대신이 <a href="/application">My URL</a>
모든 아이디어를 생성?
다음 링크를 확인했지만이 중 아무 것도이 문제를 분류하는 데 도움이되지 않았습니다. 필자는 URl Helper 대신 하드 코딩을 선호합니다.
http://framework.zend.com/manual/2.0/en/modules/zend.mvc.plugins.html#the-url-plugin
ZF2: Get module name (or route) in the application layout for menu highlight
http://framework.zend.com/manual/2.0/en/modules/zend.view.helpers.html#url-helper
ZF2 - Generating Url from route
ZF2 - Get controller name into layout/views
도대체!? 모듈 이름 앞에 기본값을 두는 것이 왜 효과가 있습니까? – MurifoX
오, 이제 알겠습니다. 이것은 바로 명명 된 경로입니다? 나는 다른 이름으로 다른 것들을 매핑하는 많은 것을 가질 수 있습니까? – MurifoX
예, 가능합니다. – akond