Reputation: 754
I'm trying to get my head around the Zend Framework.
I've created a custom route
resources.router.routes.helloworld.route = /helloworld
resources.router.routes.helloworld.defaults.module = default
resources.router.routes.helloworld.defaults.controller = helloworld
resources.router.routes.helloworld.defaults.action = display
In my hellowrold controller class I have changed the indexAction()
name to displayAction()
.
when I try to load the page in a browser I get the following error message: 'script'xxx/display.phtml' not found in path(C:/:blah blah blah)'
What am I doing wrong here?
Upvotes: 0
Views: 312
Reputation: 8855
By default Zend Framework controller actions use the ViewRenderer Controller helper. This helper reads a .phtml file related to the action as the View Script of the related action.
The controller accesses models and in the end passes the result data to view scripts, so view scripts could present the data. This is the "V" in the "MVC" abbreviation.
For your case, you have specified that your default action is named "display" instead of "index".
But I think you have forgotten to create a view script file for this action. By default the view scripts are located in the APPLICATION_PATH/application/views/scripts directory, with these assumptions:
In the above directory, each controller should have a related subdirectory, and each action have a view script file in .phtml extension.
You should create a directory called "helloworld" in there, and then create a file named "display.phtml" in that directory, so the ViewRendere controller helper class could load it and use it as the view of this action.
If you do not want to have a view script, you should prevent the ViewRendere helper from searching for a view script file. to do so, add this code to your action in the controller code:
$this->_helper->viewRenderer->setNoRender(true);
This code tells the view renderer action helper not to search for a view script file.
Please not that all the above are mentioned for a default configured Zend Framework application, but could be changed by configuring your application, resources and helper objects.
Upvotes: 2