Reputation: 691
Hello (sorry for my english...)
I got an aplication in Yii. I choose diffrent databases depending on $_GET['project']
. My urls looks like index.php?r=controler/action&project=MyProject
.
But i have to add &project=..
to every single link on my site, how can i make Yii do it automatically?
Upvotes: 0
Views: 81
Reputation: 3876
If you are using CUrlManager::createUrl()
(or one of the other createUrl()
variants) to create your links, you could override it in your own custom UrlManager
:
class UrlManager extends CUrlManager {
public function createUrl($route, $params=array(), $ampersand='&') {
isset($params['project']) || $params['project'] = 'MyProject';
return parent::createUrl($route, $params, $ampersand);
}
}
Then in your config be sure to use your own custom UrlManager
class:
return array(
...
'components' => array(
'urlManager' => array(
'class' => 'UrlManager',
),
),
...
);
Upvotes: 1