1
我試圖做使用url view helper in Zend Framework 2Zend框架2正從路徑URL
,我試圖生成URL應該 my-website.com/app/##是生成一個URL(其中##等於「OWNERID」)
當我生成這個使用這樣的視圖助手會發生什麼:
$this->url('mymodule', array('action'=>'show', 'ownerID'=>'28'));
是它只產生「my-website.com/app」,但我期望基於路由配置的「my-website.com/app/28」。
這裏是我的module.config.php文件
'router' => array(
'routes' => array(
'mymodule' => array(
'type' => 'segment',
'options' => array(
'route' => '/app',
'defaults' => array(
'controller' => 'MyModule\Controller\MyModule',
'action' => 'show',
),
),
// Defines that "/app" can be matched on its own without a child route being matched
'may_terminate' => true,
'child_routes' => array(
'archive' => array(
'type' => 'segment',
'options' => array(
'route' => '/:action[/:ownerID[/:clientID]]',
'defaults' => array(
),
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'ownerID' => '[0-9]+',
'clientID' => '[0-9]+',
)
),
),
'single' => array(
'type' => 'segment',
'options' => array(
'route' => '/:ownerID[/:clientID]',
'defaults' => array(
'action' => 'show',
),
'constraints' => array(
'ownerID' => '[0-9]+',
'clientID' => '[0-9]+',
)
),
),
)
),
)
),
路由信息時,使用這 - $>重定向會發生同樣的行爲() - > toRoute。
所有路線都按預期方式工作,當您手動鍵入它們時,它只是導致我難住的URL的一代。