2010年3月2日星期二

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

Gimme precious rew rule :)

Regards,
Saša Stamenković


On Tue, Mar 2, 2010 at 10:27 AM, Bart McLeod <mcleod@spaceweb.nl> wrote:
my 2 cents: since you probably don't want to rely on the presence of javascript, you could try writing a rewrite rule that translates the parameters to the required form...

Bart McLeod

Mon Zafra schreef:
I can see a way to do it, but it requires a 302 redirect, so your server gets hit twice after submitting. The js approach is better IMO.

// in your controller
public function init()
{
    if (!empty($_GET)) {
        $this->getHelper('Redirector')->gotoRouteAndExit($_GET);
    }
}


   -- Mon


On Tue, Mar 2, 2010 at 12:56 PM, David Muir <davidkmuir+zend@gmail.com> wrote:

Really? I'd like to know how they did that.
The only way I know of doing that would be using javascript to replace the
action on submit.

Otherwise, what you should get is:
/controller/action?param=value

with a form:
<form action="/controller/action" method="GET">
<input type="text" name="param" value="value" />
</form>

using jQuery:
$('form').submit(function(){
   $(this).attr('action', function (index, action){
       jQuery.each($(this).serializeArray(), function(i, field){
           action += '/'+field.name+'/'+field.value;
       });
       return action;
   });
});

the form should now submit to:
/controller/action/param/value

(in theory)

David
--
View this message in context: http://n4.nabble.com/Changing-get-parameters-to-controller-action-param-value-param-value-tp1574578p1574596.html
Sent from the Zend MVC mailing list archive at Nabble.com.


--
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!


没有评论: