I have my little app and now I want to add the back-end administration module. Simple task, no?
I have a bootstrap that has this thing going on:
Code: Select all
<?php
//...
$frontController = Zend_Controller_Front::getInstance();
$frontController->throwExceptions(false);
$frontController->setControllerDirectory(
array(
'default' => ROOT_DIR . '/application/controllers', //default module controllers live here!
'admin' => ROOT_DIR . '/application/admin/controllers' //and their trusty sidekick the back-end admin lives here!
)
);
$frontController->registerPlugin(new freeblankets_Controller_Plugin_ActionSetup()); //deals with the ActionStack, don't like.
$frontController->registerPlugin(new freeblankets_Controller_Plugin_ViewSetup(), 98); //ViewSetup, yadda yadda yadda
// setup the layout
Zend_Layout::startMvc(array('layoutPath' => ROOT_DIR . '/application/views/layouts',
'layout' => 'layout',
'pluginClass' => 'freeblankets_Layout_Controller_Plugin_Layout')); //Used to switch layouts between modules
Code: Select all
<?php
class freeblankets_Layout_Controller_Plugin_Layout extends Zend_Layout_Controller_Plugin_Layout
{
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
switch ($request->getModuleName())
{
case 'admin':
$this->_moduleChange('admin');
}
}
protected function _moduleChange($moduleName)
{
$this->getLayout()->setLayoutPath(
dirname(dirname(dirname( //Watch the birdie! He's vicious and he will murder you!
$this->getLayout()->getLayoutPath()
)))
. DIRECTORY_SEPARATOR . $moduleName . '/views/layouts'
);
$this->getLayout()->setLayout($moduleName);
}
}
So I goes aheads and loads the page at: http://.../public/admin (also tried with the controller name http://.../public/admin/index) and I get the following error:
Error: script 'admin.phtml' not found in path (/.../admin/views/layouts/:/.../application/views/scripts/:/.../application/admin/views/scripts/:./views/scripts/)
#0 /.../library/Zend/View/Abstract.php(783): Zend_View_Abstract->_script('admin.phtml')
#1 /.../library/Zend/Layout.php(787): Zend_View_Abstract->render('admin.phtml')
#2 /.../library/Zend/Layout/Controller/Plugin/Layout.php(142): Zend_Layout->render()
#3 /.../library/Zend/Controller/Plugin/Broker.php(331): Zend_Layout_Controller_Plugin_Layout->postDispatch(Object(Zend_Controller_Request_Http))
#4 /.../library/Zend/Controller/Front.php(945): Zend_Controller_Plugin_Broker->postDispatch(Object(Zend_Controller_Request_Http))
#5 /.../application/bootstrap.php(59): Zend_Controller_Front->dispatch()
#6 /.../public/index.php(9): Bootstrap->runApp()
#7 {main}
The rest of the site works fine, all front-end actions that load as part of the default module work exactly as they should. They load the default template and everything.
admin.phtml does, in fact, exist at /.../admin/views/layouts/
Code: Select all
<?php echo $this->doctype(); ?>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<?php echo $this->headMeta(); ?>
<?php echo $this->headTitle(); ?>
<?php echo $this->headLink(); ?>
</head>
<body>
<?php echo $this->partial("_header.phtml"); ?>
<div id="container">
<div id="content">
<?php echo $this->layout()->content; ?>
</div>
</div>
<?php echo $this->partial("_footer.phtml"); ?>
</body>
</html>
Code: Select all
<?php
class Admin_IndexController extends Zend_Controller_Action {
public function indexAction() {
//empty, just to see if the layout loads.
}
}
What am I doing wrong? Did I omit any needed information? ... used for brevity and security. My file structure, as far as I know, is totally fine since, like I said, the rest of the site works fine.