memuz
(Mh)
February 5, 2011, 11:21am
1
Hey all
i have a search form for a small site.
when i submit form i got url like that
&Car[car_make]=alfa_romeo&Car[car_model]=other&Car[location]=townhall
as i set form sending method ‘get’
Now what i want to set this as
/mk-alfa_romeo/mdl-other/location-townhall/
How can i achieve this?
Remember i am using form to send data.
1 - Should i send it first to some helper method and generate url like this ?
2 - Is there some good functionality in yii that can help me?
3 - Did someone have some functionality already?
Any advice
Thnks
memuz
(Mh)
February 9, 2011, 5:47am
2
No Idea about the solution of this question?
Is question out of scope of forum?
diggy
(Digger A)
February 9, 2011, 9:00am
3
I think that you should create javascript function that validate the search form and create an url from search form fields. url can be like this "/search/mark/model/location"
Then you submit this url.
Then you need to create some rule for your UrlManager
Can be like this one
"search/<mark:[^\/]+>/<model:[^\/]+>/<location:[^\/]+>"=>"site/search/mark/<mark>/model/<model>/location/<location>"
Then alter your controller which handling the search action:
public function actionSearch($mark, $model, $location){
// do your search here
}
Have fun
zaccaria
(Matteo Falsitta)
February 9, 2011, 9:08am
4
The form will submit to an action, you can in this action do a redirect to the page with the nice url.
The option for avoid the redirection is to use js as said diggy.
diggy
(Digger A)
February 9, 2011, 9:30am
5
zaccaria:
The form will submit to an action, you can in this action do a redirect to the page with the nice url.
The option for avoid the redirection is to use js as said diggy.
Yes, I agree. But how we can know to what action redirect? Since the user is not enter any search term?