My plugin:
<?php
class Plugin_Content extends Zend_Controller_Plugin_Abstract
{
public function dispatchLoopStartup(Zend_Controller_Request_Abstract
$request)
{
I would remove that plugin all-together and push this to your bootstrap, like
so:
https://github.com/markizano/markizano/blob/master/application/Bootstrap.php#L214
Except, instead of adding the route directly, of course you would have this
under the IF() condition expressed in your plugin.
$autoloader = new Zend_Application_Module_Autoloader(array(
'namespace' => 'Content1_',
'basePath' => APPLICATION_PATH . '/modules/content1'
));
ZF already picks up on the module autoloader, you just need to make sure you
have a module-specific Bootstrap in place:
http://framework.zend.com/manual/en/zend.loader.autoloader-resource.html
$frontController->addControllerDirectory(
APPLICATION_PATH . '/modules/content1/controllers',
'content'
);
Also, ZF picks up on what modules you have available. In
Zend_Controller_Router_Route_Module, there is a method called isValidModule,
which will check to see if the directory exists for the requested module. If the
module is present, then it passes as a module. Otherwise, ZF will revert back to
the "default" module (per your configuration), and consider the route to be a
controller.
See line 164:
http://framework.zend.com/svn/framework/standard/tags/release-1.11.5/library/Zend/Controller/Router/Route/Module.php
Hope this helps,
-Kizano
//-----
Information Security
eMail: [email protected]
http://www.markizano.net/
On 06/08/2011 10:29 AM, tridem-zend wrote:
Depending on the APPLICATION_ID my website adds different statict content
from a specific module.
F.e. APPLICATION_ID 1 catches content from /modules/content1 etc.
I would like to always call the static contents via
www.mydomain.de/content/foo.
I tried around using a plugin but I always get a Invalid controller
specified (content) message.
My structure:
/modules/default
/modules/content1
/modules/content2
My plugin:
<?php
class Plugin_Content extends Zend_Controller_Plugin_Abstract
{
public function dispatchLoopStartup(Zend_Controller_Request_Abstract
$request)
{
if (APPLICATION_ID === 1) {
$frontController = Zend_Controller_Front::getInstance();
$frontController->addControllerDirectory(
APPLICATION_PATH . '/modules/content1/controllers',
'content'
);
$router = $frontController->getRouter();
$router->addRoute(
'content',
new
Zend_Controller_Router_Route(':module/:controller/:action/*',
array(
'module' => 'content1'
)
)
);
}
}
}
--
View this message in context:
http://zend-framework-community.634137.n4.nabble.com/Dynamically-routing-a-module-to-different-controllers-tp3582673p3582673.html
Sent from the Zend Framework mailing list archive at Nabble.com.
--
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]