I'm trying to get the following route to work:
$router->add('/([a-z]{2})/:namespace/:controller/:action/([^\/]+)', array(
'language' => 1,
'namespace' => 2,
'controller' => 3,
'action' => 4,
'location' => 5
))->setName('location');
The relevant (and for testing purposes only) line in the Volt template looks like this:
{{ url({'for': 'location', 'namespace': 'weather', 'controller': 'forecast', 'action': 'precipitation', 'location': 'Hamburg' }) }}
What I want is //weather/forecast/precipitation/Hamburg but instead all I get is //weather/forecast/precipitation/.
Next thing I tried was
$router->add('/([a-z]{2})/:namespace/:controller/:action/{location:[^\/]+}', array(
'language' => 1,
'namespace' => 2,
'controller' => 3,
'action' => 4,
))->setName('location');
which at least gives me the location in the URL, but at a totally wrong position: //Hamburg/forecast/precipitation/.
Now I've looked into the Library\Mvc\Router and the array that is passed to get() looks fine to me:
Array
(
[for] => location
[namespace] => weather
[controller] => forecast
[action] => precipitation
[location] => Hamburg
[language] => en
)
I will use my own Router to handle translated URLs, so I think we can ignore the language parameter for now. So far, the custom Router does nothing more than call the original one.
Any idea how to get the location parameter to work?
I've tested all possibilities given in the router documentation and even take a look in the router implementation for Phalcon 2.0 (are you using this version, right?!). The only thing that worked out was to not use named parameters at all, even the built-in placeholders needed to be removed from the route pattern:
In other words, this seems like a bug to me. Feel free to file a bug to investigate further.
About the language parameter, I don't know if you already saw this question, but you can deal with this in a similar way.