Reputation: 85
We are creating an application where we are able to create pages inside our DB. All of our domains are going to point to this application, so we are storing our domains also in the DB. Also based on that domain we are creating new layouts and determining what pages belong to that domain. With that being said here is our issue:
We put a rule inside the urlMangaer:
'http://dev.<domain:\w+>.com'=>'site/view'
which outputs: http://dev.example.com/example/index
which represents: http://dev.$domain.com/$domain/$page
Our goal is for the url to read http://dev.$domain.com/$page
and still have the functionality we need.
Here is our action call:
public function actionView($domain = null,$page = null, $parm = null){}
A possible solution we thought of is extending the urlManager but we don't know where to begin to do so.
Upvotes: 1
Views: 182
Reputation: 85
I figured out the solution, it was in my controller all along.
I created a new function called getDomain:
public function getDomain(){
$domain = Domain::model()->find('domain_name=:domain_name', array(':domain_name'=>Yii::app()->request->baseUrl));
return $domain->domain_name;
}
then inside my actionView function
public function actionView($domain = null,$page = null, $parm = null){
if ($domain === null){
$domain = $this->getDomain();
} ...
Now it works with out the $domain having to be inside the URL
Upvotes: 0
Reputation: 571
what about defining new action in your siteController, or find a way using actionIndex, to get both domain and page as input and render the corresponding domain, page from DB.
Upvotes: 1