Hey, I built some of that!
On Wed, Feb 22, 2012 at 12:18 PM, Thomas Powers <
Thomas.Pow
...@heartland-ins.com> wrote:
> Okay. Now I am having an issue with modules. I cannot get the app to "see"
> my module. First off, I feel quite comfortable with ZF, but when it comes
> to modules, I get wrapped up in confusion. I'll try to explain the best
> that I can.
> Portion of Config File (below)
> resources.frontController.moduleDirectory = APPLICATION_PATH
> "/modules"
> resources.modules[] = ""
> ---------------End File-------------
This is correct. All your modules should reside in folders inside
APPLICATION_PATH/modules, so a new module called mynewmodule would be in
APPLICATION_PATH/modules/mynewmodules.
The second line tells it to load all the modules in the directory.
> Portion of Bootstrap File (below)
> protected function _initAutoloadModules()
> {
> $moduleLoader = new Zend_Application_Module_Autoloader(
> array (
> 'namespace' => '',
> 'basePath' => APPLICATION_PATH
> ),
> array (
> 'namespace' => 'docs',
> 'basePath' => APPLICATION_PATH .
> '/modules/docs'
> )
> );
> return $moduleLoader;
> }
You shouldn't need to do this. This is taken care of by the individual
bootstrap for each module.
> protected function _initFCPlugins()
> {
> Zend_Layout::starMvc();
> $this->bootstrap('frontController');
> $this->bootstrap('RegisterNamespaces');
> $fc = $this->getResource('frontController');
> $fc->registerPlugin(new Tws_Controller_Plugin_ModuleLayout());
> $fc->registerPlugin(new Gmic_Plugin_Module());
> return $fc;
> }
> class Gmic_Plugin_Module extends Zend_Controller_Plugin_Abstract
> {
> public function preDispatch(Zend_Controller_Request_Abstract
> $request)
> {
> $module = $request->getModuleName();
> $layout = Zend_Layout::getMvcInstance();
> $layoutsDir = $layout->getLayoutPath();
> if (file_exists($layoutsDir . DIRECTORY_SEPARATOR . $module
> . ".phtml")) {
> $layout->setLayout($module . "-layout");
> } else {
> $layout->setLayout('layout');
> }
> }
> }
Gmic_Plugin_Module seems to be doing the same thing as what
Tws_Controller_Plugin_ModuleLayout() is intended to do, which is flip the
layout file based on the module name. So you could probably get rid of it.
> ---------------End File--------------
> I'm trying to access APP_PATH . "/agent/docs/index". There are two
> modules, I have the default and then docs (at this point). As you can see
> from the parameters list at the bottom, the module is docs, the controller
> is index, yet it doesn't "exist".
> <***** ERROR THAT I GET ******>
> An error occurred
> Page not found
> Exception information:
> Message: Action "index" does not exist and was not trapped in __call()
> Stack trace:
> #0
> /var/www/projects/powerst/shared-library/Zend/Controller/Action.php(515):
> Zend_Controller_Action->__call('indexAction', Array)
> #1
> /var/www/projects/powerst/shared-library/Zend/Controller/Dispatcher/Standar d.php(289):
> Zend_Controller_Action->dispatch('indexAction')
> #2
> /var/www/projects/powerst/shared-library/Zend/Controller/Front.php(946):
> Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Reques t_Http),
> Object(Zend_Controller_Response_Http))
> #3
> /var/www/projects/powerst/shared-library/Zend/Application/Bootstrap/Bootstr ap.php(77):
> Zend_Controller_Front->dispatch()
> #4 /var/www/projects/powerst/shared-library/Zend/Application.php(346):
> Zend_Application_Bootstrap_Bootstrap->run()
> #5 /var/www/projects/powerst/agent/public/index.php(35):
> Zend_Application->run()
> #6 {main}
> Request Parameters:
> array(3) {
> ["module"]=>
> string(4) "docs"
> ["controller"]=>
> string(5) "index"
> ["action"]=>
> string(5) "index"
> }
> ------------- END ERROR ------------
> I have a bootstrap for the docs module, as well. The IndexController for
> Docs is Docs_IndexController. Anyone know what I'm missing here?
It all sounds correct. Your directory layout should look like this:
/path/to/application/
application/
configs/
controllers/
forms/
layouts/
models/
modules/
docs/
controllers/
forms/
....
views/
Make sure that you have a bootstrap class in
application/modules/docs/Bootstrap.php that looks like this one:
https://github.com/dragonmantank/manuscript/blob/master/application/m...
(replace
Accelerators_Boostrap with Docs_Bootstrap). That should cause ZF to see
your module controllers.
My guess is all that is correct, and if it is I think you're just missing
the indexAction() method in Docs_IndexController. So it would look like
this:
class Docs_IndexController extends Zend_Controller_Action
{
public function indexAction() {
// Logic for this page
}
}
> THOMAS POWERS | SENIOR WEB DEVELOPER |
> GERMAN MUTUAL INSURANCE
> Work: (419) 599-3993 Ext: 252 | Mobile: (419) 591-6064 |
> Email: thomas.pow...@heartland-ins.com | Website:
> http://www.heartland-ins.com
> Tuesdays & Fridays: (419) 966-4079
> "True patriotism is more closely linked to dissent than it is to
> conformity and a blind desire for safety and security." - Congressman Ron
> Paul (TX)
--
Chris Tankersley
http://ctankersley.com 419.785.6408