【发布时间】:2014-12-10 17:54:55
【问题描述】:
我正在尝试使用以下路线:
$router->add('/([a-z]{2})/:namespace/:controller/:action/([^\/]+)', array(
'language' => 1,
'namespace' => 2,
'controller' => 3,
'action' => 4,
'location' => 5
))->setName('location');
Volt 模板中的相关(仅用于测试目的)行如下所示:
{{ url({'for': 'location', 'namespace': 'weather', 'controller': 'forecast', 'action': 'precipitation', 'location': 'Hamburg' }) }}
我想要的是 //weather/forecast/precipitation/Hamburg,但我得到的却是 //weather/forecast/precipitation/。
接下来我尝试的是
$router->add('/([a-z]{2})/:namespace/:controller/:action/{location:[^\/]+}', array(
'language' => 1,
'namespace' => 2,
'controller' => 3,
'action' => 4,
))->setName('location');
这至少给了我 URL 中的位置,但位置完全错误://Hamburg/forecast/precipitation/。
现在我查看了 Library\Mvc\Router,传递给 get() 的数组对我来说看起来不错:
Array
(
[for] => location
[namespace] => weather
[controller] => forecast
[action] => precipitation
[location] => Hamburg
[language] => en
)
我将使用我自己的路由器来处理翻译后的 URL,所以我认为我们现在可以忽略语言参数。到目前为止,自定义路由器只是调用原始路由器。
知道如何让位置参数起作用吗?
【问题讨论】:
标签: php phalcon phalcon-routing