I'm having and issue with the view helper function this->url() that doesn't return and url from a child route and I get a White Screen of the dead. When I put the url manually in the browser the router recognizes the url well.
I have this in my module.config.php:
'news' => array(
'type' => 'Segment',
'options' => array(
'route' => '/news[/:id]',
'constraints' => array(
'id' => '[0-9]+',
),
'defaults' => array(
'controller' => 'Application\Controller\News',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'allnews' => array(
'type' => 'Segment',
'options' => array(
'route' => '[/:action[/:tab[/:page]]]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'tab' => '[0-9]+',
'page' => '[0-9]+',
),
'defaults' => array(
'controller' => 'Application\Controller\News',
'action' => 'all',
'tab' => 1,
'page' => 1,
),
),
),
),
),
For example:
/news/2
Works correctly and matches the parent route
And:
/news/all/2/5
Works correctly and matches the child route.
But when I use this in the view-helper I get a White Screen of the Dead:
echo($this->url('news/allnews', array('action' => 'all', 'tab' => '1', 'page' => '1')));
My question is: What it's wrong?? I used this method in others views and worked well.
You do not need to use child routes in combination with Router Segments. One Segment should be sufficient!
As long as the Defaultcontroller is sufficient you for your needs you also would not need to have it within your params. Once you need more then 1 you prob want to have another constraint defining the controller.
Now you could simply use the url viewhelper in various ways.
Ideally I would use a Router Literal with Router Segments as child routes since bombarding the router segment with tons of constraints gets messy pretty fast.