I'm working on a Zend project and I have some issues with the router/routes.
I want the have these URLs:
The third segment in the URL will be a fixed text "formsend" or it will contain an ID, which is a number like '123456789'.
URL 1 and 3 should both execute the indexAction()
, URL 2 must execute the sendAction()
.
Now I have these route's setup to get URL 1 and 2 working:
return array(
'router' => array(
'routes' => array(
'contact' => array(
'type' => 'Segment',
'options' => array(
'route' => '/contact[/][:dns]',
'defaults' => array(
'__NAMESPACE__' => 'project\Controller',
'controller' => 'Contact',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'send' => array(
'type' => 'Segment',
'options' => array(
'route' => '[/[:action[/]]]',
'defaults' => array(
'action' => 'send'
),
),
),
),
),
I have no idea how I must change my routes so I would be able to have segment_3 inside the indexAction()
. What do I need to change?
It sounds to me you only need two routes:
First define /contact/:type/formsend
, then /contact/:type[/:id]
.
You can make them children of a top-level (non-terminating) /contact
or /contact/:type
route, or not.