If you follow the QuickStart[1] when building your app, your application.ini
will have a line like this:
resources.view[] =
That will initialize the built-in view resource.
But if that line isn't there, the "view renderer" action controller help
will lazy-load its own view instance, so that line isn't 100% required
unless you want to access the view from somewhere other than an action
controller (as in OP's case).
If you are not using the view resource, the alternative to getting the view
instance is to pull it form the view renderer:
$viewRenderer =
Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
if (null === $viewRenderer->view) {
$viewRenderer->initView();
}
$view = $viewRenderer->view;
1.
http://framework.zend.com/manual/en/learning.quickstart.create-layout.html
--
Hector
On Fri, Apr 9, 2010 at 1:50 PM, Chris Trahey <[email protected]> wrote:
> As far as I know, that translates to needing at least *some* mention of the
> view in the application.ini...
>
> Is this true?
>
> To clarify then, you need *either* an _initView(), or you can setup the
> default plugin by providing at least one line in application.ini such as:
> resources.view.encoding = "UTF-8"
>
> or, of course, provide a custom resource plugin of your own and configure
> that in application.ini.
>
> Anyway, I probably sound like a pest, but I think it's worth clarifying,
> since the line
> $view =
> Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('view');
>
> will not work "out of the box".
>
> Is this thinking correct? I appreciate your input as I get to know the
> framework deeper....
>
> Chris Trahey
>
> Web Applications Developer
>
> Database Administrator
>
> CSISD [Technology]
>
>
>
> On Thu, Apr 8, 2010 at 9:55 AM, Jurian Sluiman <[email protected]
> > wrote:
>
>> On Thursday 08 Apr 2010 15:58:25 Саша Стаменковић wrote:
>> > Are you sure?
>>
>> No, that's not correct. To retrieve the resource, you need either an
>> _init*()
>> method or use a bootstrap plugin. The resource is initialized when you
>> bootstrapped it (e.g. configured the resource in the application.ini).
>>
>> And because Zend delivers a view resource plugin by default, there is no
>> need
>> for a custom _initView() method.
>>
>> > On Wed, Apr 7, 2010 at 10:37 PM, Chris Trahey <[email protected]>
>> wrote:
>> > > umpirsky wrote:
>> > >
>> > >
>> > >
>> Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource(
>> > > 'view');
>> > >
>> > >
>> > > Note that for this to work (I'm using 1.10), you need a bootstrap
>> method
>> > > named _initView that returns your view object.
>>
>> --
>> Jurian Sluiman
>> CTO Soflomo V.O.F.
>> http://soflomo.com
>>
>
>