Zend framework multiple routes for same controller

I'm trying to set up Zend pagination on my site so that I can use Paul Irish's jquery infinite scroll plugin, but I'm having trouble with my routes. I currently have these routes set up for my organizer page:

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

It matches organizer/index/popular correctly in this order, but if I put a page number on it the filter suddenly comes up null. If I switch the order, organizer/index/popular/2 works perfectly fine but organizer/index/popular no longer works. I could just only use the more specific route since that's the one I'll need for pagination, but I would like to include both to accommodate users trying to type the url or in case I forget to change the links somewhere in my code. Can I incorporate multiple routes to the same controller with Zend? If so, what am I doing wrong?


You need to give the routes different names. You've called them both 'organizer', so the second one replaces the first each time.

You could also easily do this with one route simply by setting a default value for the page variable:

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

Every route you add to the router must a have a unique name, so the second route you want to add must have a different name, because with your current code you overwrite the route organizer. Change the second call of $router->addRoute() to something like this:

$router->addRoute('organizer2', $route );

Need Your Help

Change the color of x and y axis of a graph from a GUI in MATLAB

matlab colors plot matlab-guide

I am trying to change the color of a graph I created in MATLAB GUIDE. I initially set the colors of the x-axis and y-axis to be white in GUIDE but whenever I output to the graph, the both axes change