Hi so lets say I have a business name in my table: business called = "Romano Pizza".
I’d like users to be able to type, www.mydomain.com/businesss/Romano Pizza
and it redirect the user and do the view(id) of that business.
I’m unsure how to do this, I would assume it has something to do with the url management thing.
perochak
(Amjad Mughal)
2
You can do this as
with id and title
in your config/main.php in urlManager
you need to have things like as
'/business/<id:\d+>/<title:\w+>'=>'business/view'
This will do a url as
domain.com/business/1/perochak
But if you want to have as
domain.com/business/perochak
Then you need to have either a column named url which must be unique and urlManager as
'/business/<url:\w+>'=>'business/view'
But if you still would like to have the url as
domain.com/business/perochak
without any new column in db, then do it like as, in UrlManager
'/business/<title>'=>'business/view'
in actionView as
$title= Yii::app()->request->getQuery('title');
$entry= Entry::model()->find("title='".$title."'");
Enjoy the way you want…
YII