Hi guys,
I’m just don’t getting a way to solve this problem. Check this out.
I have a form with GET method and action :
'action'=>$this::createUrl('busca/buscaGenerica')
The form generate a URL like this:
/busca/buscaGenerica?search=teste&btn_search=Buscar
I want to convert that to this:
/veiculos/teste/Buscar
In the UrlManager i tried this rule, but isn’t working:
'veiculos/<search>/<btn_search>' => 'busca/buscaGenerica',
Ideas?
Regards
softark
(Softark)
July 26, 2012, 3:45am
3
Maybe this:
'veiculos/<search:\w+>/<btn_search:\w+>' => 'busca/buscaGenerica',
Yeah, i tried this…but don’t works.
softark
(Softark)
July 26, 2012, 4:27am
5
I see.
In order to use the urlManager rule, you will need something like this:
$this::createUrl('busca/buscaGenerica', array('search' => $search_word, 'btn_search' => $btn_name)
Of course, I don’t think you can get $search_word and $btn_name before you submit the form …
Well, sorry, I’m lost too.
Look…if i try access the page using manually writing the url path, works fine, like this:
/busca/buscaGenerica/search/dd/btn_search/Buscar
But, my problem is…in the form, the URL don’t rewrite do path format.
Look my htaccess file:
RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST-FILENAME} !-d
#otherwise forward it to index.php
RewriteRule ^.*$ index.php [NC,L]
well…
/veiculos?search=ddd&btn_search=Buscar
Still sucks.
softark
(Softark)
July 26, 2012, 5:07am
9
The urlManger rules work on the server side, while your "search" word and "btn_search" name are determined on the client side in a form.
So, I guess you can’t get the right url by any urlManager rule. It will contain the query string part like ‘?search=xxxx&btn_search=yyyy’.
I would use a script to catch the submit event of the form and construct the right url on the fly and call it.
Well, are you sure about that?
I’ve seen some cases in the forum, people who managed to get the URLs working properly.
I’m just not getting. With me the solutions to this problem don’t work fine.
softark
(Softark)
July 26, 2012, 3:52pm
11
As far as I understand, yes.
Another solution may be using redirection.
dyegonery
(Dyegonr)
August 15, 2012, 2:47am
12
Well, this problem still breaking my job.
Someone else could help me with this issue?
Hugs
alirz23
(Alirz23)
August 15, 2012, 8:05am
13
create an empty action in you controller something (e.g. search)
and you can do something like following in your search action
$this->redirect(array("searchresult/{$_GET['params1']}/$_GET['param2']"));
dyegonery
(Dyegonr)
August 15, 2012, 11:01pm
14
Seems that will work this way.
But this way would not be a bit wrong?
I myself have seen the same problem being solved just with rules in urlManager.