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