I have the following code using normal Zend routing and I need to convert it into Zend routing using XML:
$route = new Zend_Controller_Router_Route_Regex(
'test/v([0-9]+)-([0-9A-Za-z-:?&\'() ]+)\.html',
array(
'action' => 'someAction',
'controller' => 'someController'
),
array(
1 => video_id
),'test/v%d-%s.html');
$router->addRoute('some-Action', $rou开发者_StackOverflowte);
How can I pass parameters in XML and what is the basic syntax of this route in XML?
How's this? You may want to add the second matched part to a variable too, though.
<router>
<routes>
<some-action>
<type>Zend_Controller_Router_Route_Regex</type>
<route>test/v([0-9]+)-([0-9A-Za-z-:?&\'() ]+)\.html</route>
<defaults>
<controller>someController</controller>
<action>someAction</action>
</defaults>
<map>
<video_id>1</video_id>
</map>
<reverse>test/v%d-%s.html</reverse>
</some-action>
</routes>
</router>
To use it, you can add it directly to your router:
$front = $this->getResource('frontcontroller');
$router = $front->getRouter();
$config = new Zend_Config_Xml(APPLICATION_PATH . '/configs/routes.xml');
$router->addConfig($config->routes);
精彩评论