Skip to end of metadata
Go to start of metadata

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[]]></ac:plain-text-body></ac:macro>

<p><ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[]]></ac:plain-text-body></ac:macro> <strong>Where's the model?</strong></p>
<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[]></ac:plain-text-body></ac:macro>
<p>Unlike the view and the controller components, the model component can vary dramatically in responsibilities and data storage from one MVC application to the next. It should represent what your application does in the abstract. The Zend Framework community has not defined a model interface, class, or other formalism because we haven't identified enough added value to justify limitations on what constitutes a model.</p>
<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[]
]></ac:plain-text-body></ac:macro>

<p><ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[]]></ac:plain-text-body></ac:macro> <strong>How can I retrieve the view object within a plugin or arbitrary code?</strong></p>

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[]></ac:plain-text-body></ac:macro>
<p>ZF uses an action helper called the ViewRenderer by default. This action helper instantiates and stores a Zend_View object, which is subsequently injected into other objects. The view object is stored in the ViewRenderer's view property. You can get the ViewRenderer instance, and thereby the view instance, with the Action Helper broker:</p>

<ac:macro ac:name="code"><ac:default-parameter>php</ac:default-parameter><ac:plain-text-body><![CDATA[
$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer';
$view = $viewRenderer->view;
]]></ac:plain-text-body></ac:macro>

<p>However, if you're accessing the view early in the dispatch process- before an action is actually dispatched, for example- then you may need to initialize the view first:</p>

<ac:macro ac:name="code"><ac:default-parameter>php</ac:default-parameter><ac:plain-text-body><![CDATA[
if (!isset($viewRenderer->view)) {
$viewRenderer->initView();
}
$view = $viewRenderer->view;
]]></ac:plain-text-body></ac:macro>

<p>If you are using and have already initialized Zend_Layout, you can access the view object much more succinctly:</p>

<ac:macro ac:name="code"><ac:default-parameter>php</ac:default-parameter><ac:plain-text-body><![CDATA[
$view = Zend_Layout::getMvcInstance()->getView();
]]></ac:plain-text-body></ac:macro>

<p>This proxies to the ViewRenderer and performs all of the steps above for you.</p>
<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[]]></ac:plain-text-body></ac:macro>

<p><ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[]]></ac:plain-text-body></ac:macro> <strong>I'm using the ContextSwitch or AjaxContext view helper and receiving an exception indicating the error.ajax.phtml view script is missing; what am I doing wrong?"</strong></p>

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[]></ac:plain-text-body></ac:macro>
<p>ContextSwitch makes the assumptions that (a) you are not calling <code>_forward()</code> and (b) that your application code will not throw an exception. If you see the above error, your code is throwing an exception - but the context is still in play, and the ViewRenderer is simply trying to load a view script for the current context from the ErrorController.</p>

<p>The easiest way to fix the situation is to have the <code>ErrorController::errorAction()</code> redefine the view script suffix, as follows:</p>

<ac:macro ac:name="code"><ac:default-parameter>php</ac:default-parameter><ac:plain-text-body><![CDATA[
class ErrorController extends Zend_Controller_Action
{
public function errorAction()

Unknown macro: { $this->_helper->viewRenderer->setViewSuffix('phtml'); // ... }

}
]]></ac:plain-text-body></ac:macro>
<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[]]></ac:plain-text-body></ac:macro>

<p><ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><Unable to render embedded object: File (plain-text-body></ac:macro> <strong>I'm using Apache, and passing urlencoded slashes via $_GET or as URL parameters – and I'm getting 404s) not found.</strong></p>

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[]></ac:plain-text-body></ac:macro>
<p>Apache by default disallows urlencoded slashes (i.e., "%2F") in URL path parts or the query string. This feature can be disabled by enabling the "AllowEncodedSlashes" directive:</p>

<ac:macro ac:name="code"><ac:plain-text-body><![CDATA[
AllowEncodedSlashes On
]]></ac:plain-text-body></ac:macro>

<p>However, this directive must be set at either a server-wide (httpd.conf) or virtual-host level.</p>

<p>For more information, <a href="http://httpd.apache.org/docs/2.0/mod/core.html#allowencodedslashes">read the AllowEncodedSlashes documentation</a>.</p>
<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[]]></ac:plain-text-body></ac:macro>

Labels:
None
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.