
h1. Frequently Encountered Problems
h3. A list of frequently encountered problems that occur from simple mistakes or by those who simply "forgot" about what the manual said...
----
|| Problem || Answer ||
| Why is it rendering a view when I never told it too? \\
\\
Or: Why am I gettin a "Zend_View_Exception" about a script not being found? \\ | ViewRenderer was added in RC1 which renders views automatically, based on your controller/action name, have a look at [Zend Framework's MVC Introduces the ViewRenderer|http://devzone.zend.com/article/2072-Zend-Frameworks-MVC-Introduces-the-ViewRenderer] and the [the manual on action helpers|http://framework.zend.com/manual/en/zend.controller.actionhelpers.html#zend.controller.actionhelper.stockhelpers] |
| How do I disable ViewRenderer then? \\ | Simply set the 'noViewRenderer' controller param which will disable it completely: \\
{code}
$front->setParam('noViewRenderer', true); //Assuming $front is your front controller instance
{code}\\
You can read the ViewRenderer section of the manual for more precise control, see [ViewRenderer Manual|http://framework.zend.com/manual/en/zend.controller.actionhelpers.html#zend.controller.actionhelpers.viewrenderer] |
| How do I use a common header and footer in my View templates? \\ | At the moment, the Zend Framework 1.0.0 doesn't have an "officially blessed" solution, so there are multiple approaches being used: \\
# Front Controller plug-in: [Controller and View Question|http://www.nabble.com/Controller-and-View-Question-tf3462561.html]
# Zend_Layout proposal: [Zend_Layout|http://framework.zend.com/wiki/display/ZFPROP/Zend_Layout] ([Xend Layout tutorial|http://www.spotsec.com/blogs/archive/the-basics-of-zend_layout-ahem-xend_layout.html])
# Zend_View Enhanced proposal: [Zend_View_Enhanced|http://framework.zend.com/wiki/pages/viewpage.action?pageId=33071]
# Extend ViewRenderer directly: [Extending ViewRenderer|http://akrabat.com/2007/06/02/extending-viewrenderer-for-layouts/]
# If the above fail (or seem too complicated), you can render alternative view scripts from your views: \\
{code}
<?php echo $this->render('index/header.phtml'); ?>
{code} |
| Why am I getting an exception with the message 'Invalid controller specified (error)' | You haven't set up an ErrorController to catch errors. By default the framework has a front controller plugin that tries to send all exceptions to a special controller (ErrorController in the default module). There's a sample error controller, and more information on the plugin, in the [manual|http://framework.zend.com/manual/en/zend.controller.plugins.html#zend.controller.plugins.standard] |
| Why am I getting an exception about "error.phtml" was not found? \\ | This has to deal partly with ViewRenderer rendering view automatically, but more importantly, it occurs because there was an error somewhere and you were redirected to the ErrorController, but error.phtml could not be rendered, generating another error. \\ |
| I'm having problems loading files, getting a "No such file" error. \\ | \\
You may have one of the following problems: \\
* You didn't set up your include path right, make sure the library is included. Set it on top of your bootstrap, before any require_once or Zend_Loader::loadClass() statements.
* You've specified the library ending in 'Zend' (make sure it's /path/to/your/library, not /path/to/your/library/Zend/)
* You're trying to load a model in a "models" directory, without having it set in your include path, have a look at [Spotsec's model loader|http://www.spotsec.com/blogs/archive/zend-model-loading-modelloader.html?Itemid=125] |
| How do I create urls like this "/index/about" for Zend Framework? \\ | Zend Framework has a url view helper and a url action helper to generate urls for you. You can read about them more in this blog article: [Use the url helper please|http://naneau.nl/2007/07/08/use-the-url-view-helper-please/] \\ |