Static content not displayed with Zend FW
- by shin
I am trying to display a static content with Zend framework.
When I go to http://square.localhost/content/services, I get an error message.
Could anyone tell me how to fix this please?
Thanks in advance.
application.ini
....
....
resources.layout.layoutPath = APPLICATION_PATH "/layouts"
resources.layout.layout = "master"
resources.router.routes.home.route = /home
resources.router.routes.home.defaults.module = default
resources.router.routes.home.defaults.controller = index
resources.router.routes.home.defaults.action = index
resources.router.routes.static-content.route = /content/:page
resources.router.routes.static-content.defaults.module = default
resources.router.routes.static-content.defaults.controller = static-content
resources.router.routes.static-content.defaults.action = display
application/modules/default/controllers/StaticContentController.php
class StaticContentController extends Zend_Controller_Action
{
public function init()
{
}
// display static views
public function displayAction()
{
$page = $this->getRequest()->getParam('page');
if (file_exists($this->view->getScriptPath(null) . "/" . $this->getRequest()->getControllerName() . "/$page." . $this->viewSuffix)) {
$this->render($page);
} else {
throw new Zend_Controller_Action_Exception('Page not found', 404);
}
}
}
application/modules/default/views/scripts/static-content/services.phtml
some html
...
...
Error message
An error occurred
Page not found
Exception information:
Message: Page not found
Stack trace:
#0 /var/www/square/library/Zend/Controller/Action.php(513): StaticContentController->displayAction()
#1 /var/www/square/library/Zend/Controller/Dispatcher/Standard.php(295): Zend_Controller_Action->dispatch('displayAction')
#2 /var/www/square/library/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#3 /var/www/square/library/Zend/Application/Bootstrap/Bootstrap.php(97): Zend_Controller_Front->dispatch()
#4 /var/www/square/library/Zend/Application.php(366): Zend_Application_Bootstrap_Bootstrap->run()
#5 /var/www/square/public/index.php(26): Zend_Application->run()
#6 {main}
Request Parameters:
array (
'page' => 'services',
'module' => 'default',
'controller' => 'static-content',
'action' => 'display',
)