0

I just set up a couple routes in the bootstrap of my Zend site, here's one of them:

$route = new Zend_Controller_Router_Route('organizer/haveItem',
                                                array('controller'=> 'organizer',
                                                'action'=> 'haveItem')); 
    $router->addRoute('have', $route);

The other new one is essentially identical, replace 'have' with 'want'. I did this so that any Ajax calls would be caught by these routes instead of falling into my index action, at which point they're basically lost forever because if I try to redirect to the correct actions from there I just get stuck in an infinite loop.

My problem is that when I use these routes, I get a 500 error. I believe it's because either these routes are lopping off the parameterized variables from the Ajax call, or because any parameterized variables are causing the calls to not match these routes and fall into the index action. Would that in fact cause the 500 error, and if so, how can I adjust these routes to account for Ajax post variables?

jaimerump
  • 882
  • 4
  • 17
  • 35

1 Answers1

0

Zend's router can pass ajax variables through routes perfectly fine. The problem was that I had multiple routes to the same controller. Right below the have and want routes I had this one:

$route = new Zend_Controller_Router_Route('organizer/:filter/:page',
                                                array('controller'=> 'organizer',
                                                'action'=> 'index',
                                                'page'=>1)); 
    $router->addRoute('organizer searches', $route);

Which was catching my have and want calls. When I moved this one up to the top of the list it worked perfectly fine. I believe the Zend router evaluates routes from the bottom up, as noted in the Zend documentation http://framework.zend.com/manual/en/zend.controller.router.html, so you have to stick the more specific routes toward the bottom of the list. For instance, all of my routes with a keyword after the organizer segment have to be below any routes with :filter so that they get caught first.

jaimerump
  • 882
  • 4
  • 17
  • 35