-- Tom Graham <[EMAIL PROTECTED]> wrote
(on Tuesday, 02 September 2008, 07:18 AM +0100):
> I am writing a custom default router where by the module is dependent on
> the sub-domain, for example:
>
> domain.com -> default
> www.domain.com -> default
> admin.domain.com -> admin
> anything-else.domain.com -> account
>
> The theory behind this is similar to the following in rails:
> http://wiki.rubyonrails.org/rails/pages/HowToUseSubdomainsAsAccountKeys
>
> My router is based on Zend_Controller_Router_Route_Module, however
> adding the route in my bootstrap class it is always NULL.
There is now special hostname-based routing available with the 1.6.0
series:
http://framework.zend.com/manual/en/zend.controller.router.html#zend.controller.router.routes.standard.hostname-routing
I'd check that option out, personally. :)
> $dispatcher = $this->_controller->getDispatcher();
> $request = $this->_controller->getRequest();
> $router = $this->_controller->getRouter();
> $router->addRoute('default', new
> App_Controller_Router_Route_AccountKey(array(), $dispatcher, $request));
>
> I have managed to solve the problem by instantiating a request object
> and assigning it to the front-controller as well as passing it to the
> route.
>
> $dispatcher = $this->_controller->getDispatcher();
> $request = new Zend_Controller_Request_Http();
> $this->_controller->setRequest($request);
> $router = $this->_controller->getRouter();
> $router->addRoute('default', new
> App_Controller_Router_Route_AccountKey(array(), $dispatcher, $request));
>
> Is this my only option and is it the right one? My router seems to work
> well other than this but I would be interested to hear about any other
> custom routers people have written that do the same job.
>
> Thanks,
>
> Tom
>
--
Matthew Weier O'Phinney
Software Architect | [EMAIL PROTECTED]
Zend Framework | http://framework.zend.com/