2010年3月11日星期四

Re: [fw-mvc] Re: Changing get parameters to controller/action/param/value/param/value

Take for example this site http://www.musicbackingtracks.co.uk/tracks/search/artist/creed, I just picked a site build with codeigniter, that has a search form. The parameter is artist, with a value of creed. They are able to get nice looking url's with search forms, that's what I am really looking for. SEO is the main concern that I have, it's not really about looking good in a browser.
 
-Andy

Sent: Tuesday, March 09, 2010 5:08 AM
Subject: Re: [fw-mvc] Re: Changing get parameters to controller/action/param/value/param/value

in your view script, where you use the helper.

The url in the browser will only look like this after you click the link generated by the view helper.

Is it only about a good looking url in the browser? The get request from a search form for example will still have the question mark. But I cannot see the problem with that.

Bart


Op 8-3-2010 19:24, Andy Daykin schreef:
So where in my code would I put:
 
$url = $view->url($_GET)
 
Is that something that should be added in the bootstrap. Will the actual url in the browser look like
http://example.com/controller/action/param/value
?
 
Thanks,
 
-Andy

Sent: Monday, March 08, 2010 6:18 AM
Subject: Re: [fw-mvc] Re: Changing get parameters to controller/action/param/value/param/value

Hi Andy,

I probably posted to the wrong list, so you may have missed it. I set out to fix a couple of issues with the Zend_View_Helper_Url.

No one objected to that, so I also filed your issue in the issue tracker and assigned it to myself.

I did not yet look into it much, but it seems that how the url is assembled in the view helper  depends on which type of router is in use at that moment.

There a quite a few router types, so I must first choose if all routers can be made to preserve get parameters in the new form and if this will brake people's applications if they rely on the helper not preserving the get params.

In the meanwhile, while trying to write up a testcase for Zend_View_Helper_Url, I found that what you are trying to achieve can be simply accomplished by writing:

$url = $view->url($_GET);

This will put all of your $_GET parameters in the form you desire.

I accidentally stumbled upon this and I now realize that I must update the issue and resolve it with this tip.

Regards,

Bart McLeod

Andy Daykin schreef:
My intent was to find a way to change the part of the code where the get variables are picked up, so I can do:
 
$this->getRequest()->getParam('param');
 
 
 
using something like $request_uri = preg_replace("|/(.*)|", "\\1", str_replace("\\", "/", $_SERVER['REQUEST_URI']));
 
So I would be manipulating the url that comes in and the variable from where the getParam method takes in the get parameters.
 
What variables would I need to change if I wrote a function in the bootstrap?
 
-Andy

Sent: Wednesday, March 03, 2010 3:34 AM
Subject: Re: [fw-mvc] Re: Changing get parameters to controller/action/param/value/param/value

Guys, it's not just for better looking urls.

There is another problem with  /controller/action?param=value, url helper don't see get parameters, it only see parametersif they are zf style, so param will not be handled by url helper if it is not in zf param style.

People coming up with their own implementations for url helper which handles this, example http://robertbasic.com/blog/myurl-view-helper-for-zend-framework/


Regards,
Saša Stamenković


On Wed, Mar 3, 2010 at 10:03 AM, Bart McLeod <mcleod@spaceweb.nl> wrote:


David Muir schreef:
That would only be necessary if the desired form were actually required.  Zend's default router sees them as being equivalent: /controller/action/param/value /controller/action?param=value  so in both cases $this->getRequest()->getParam('param'); //returns 'value'  However, if you're wanting something like: /search/value   
For this, you only need a custom route. No extra rewrite.
The point in the original post is that for some unknown reason the get url should be consistent with the other urls in the application.
So the question is how can we make /controller/action?param=value appear as /controller/action/param/value
But the more important question, as pointed out by Andreas is "Why?"

then yes, you'll need to do the rewrite server-side.      

--
Bart McLeod
Space Web
Middenlaan 47
6865 VN Heveadorp
The Netherlands
t +31(0)26 3392952
m 06 51 51 89 71
@ info@spaceweb.nl
www.spaceweb.nl
zce logozce PHP 5 logo zce Zend Framework logo

Bart McLeod is a Zend Certified Engineer.

Click to verify!



--
Bart McLeod
Space Web
Middenlaan 47
6865 VN Heveadorp
The Netherlands
t +31(0)26 3392952
m 06 51 51 89 71
@ info@spaceweb.nl
www.spaceweb.nl
zce logozce PHP 5 logo zce Zend Framework logo

Bart McLeod is a Zend Certified Engineer.

Click to verify!


--
Bart McLeod
Space Web
Middenlaan 47
6865 VN Heveadorp
The Netherlands
t +31(0)26 3392952
m 06 51 51 89 71
@ info@spaceweb.nl
www.spaceweb.nl
zce logozce PHP 5 logo zce Zend Framework logo

Bart McLeod is a Zend Certified Engineer.

Click to verify!

没有评论: