0
我正在尝试在ZF2项目中创建动态路线。它会像“domain.com/companyurl/products”。公司网址是动态的。我做到了:ZF2-动态基础路线
'company' => array(
'type' => 'Segment',
'options' => array(
'route' => '[/:company]',
'defaults' => array(
'controller' => 'IndexController',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
...
),
),
但我总是必须通过公司参数的路线。
$this->url('company/products', array('company' => 'companyurl'));
有没有一些方法可以在运行时指定一个基本路由,比如一个基础url,那么所有的路由都会跟着它?事情是这样的:
$this->url('products');
或
$this->url('company/products');
在这两种情况下,我已经规定的基本路线值。
我希望你明白我的意思。谢谢。
你可以继承URL视图助手(Zend \ View \ Helper \ Url)以自动为所有的URL添加公司URL。 – Ed209