Routes should be defined in a bootstrap or in a routeStartup() of a front controller plugin. When the dispatch loop reaches the controller, the router has already been invoked so any rules you add inside controllers are useless (they can still be used to generate URLs in the controller and view, but without the corresponding routing rule the URLs generated would probably lead to nowhere unless the said rule is a subset of an existing rule or the default one).
Module-specific rules are impossible for the same reason. The closest thing to such a thing is to have rules defined in module bootstraps which are loaded in every request. They are not really module-specific rules though, but merely routing rules that are organized per module. I do exactly that in http://code.google.com/p/mz-project/ . -- Mon On Mon, Mar 2, 2009 at 8:33 PM, vadim gavrilov <vadim...@gmail.com> wrote: > Thanks i already looked at those files. Still can i place an instance of > the addRoute inside a certain controller? or do i need to place it somewhere > in the bootstarp file? Basically what i would like to do is to make a file > that will hold all the routes for each module/controller. Did anyone made > something like that before? > > Thanks. > > > On Mon, Mar 2, 2009 at 2:22 PM, Jens Kleikamp <j...@codes-concepts.com>wrote: > >> vadim gavrilov wrote: >> >>> Where exactly do you place the router? In the bootstrap file? in the >>> index? >>> How can you make a custom router for each module you have? Examples will >>> be >>> highly appreciated. >>> >>> You can take a look at Matthews Pastebin application. He uses a modular >> directory structure and each module has its own bootstrap class. In these >> classes you have access to the Initialize plugin and the frontcontroller >> instance. >> >> >> http://github.com/weierophinney/pastebin/blob/b796ad0e5905e46b312a5b904a2a80c3ed8ff808/library/My/Plugin/Initialize.php >> >> http://github.com/weierophinney/pastebin/blob/b796ad0e5905e46b312a5b904a2a80c3ed8ff808/application/modules/spindle/Bootstrap.php >> >> Now you can use the getRouter() method of the frontcontroller and then add >> new custom routes with addRoute(). >> >> >> Hope this helps. >> >> >> >> >> >> >> >> > > > -- > Vincent Gabriel. > Lead Developer, Senior Support. > Zend Certified Engineer. > > > > >