views:

22

answers:

1

Is it possible to choose controller from Plugin?

For example I have table of departments and categories in database. I'm fetching them and want to make certain actions(picking controller and action).

The reason - I don't want to create sepparate controller for each department and action for each category.

+1  A: 

You may do the following:

class Content_Plugin extends Zend_Controller_Plugin_Abstract
{
  public function routeShutdown(Zend_Controller_Request_Abstract $request)
  {
    // fetching departments and categories
    // ...

    $request->setControllerName('my'); // will map class MyController
    $request->setActionName('special');  // will map MyController::specialAction();
  }
}
Gixx