-- David Di Biase <[EMAIL PROTECTED]> wrote
(on Friday, 02 May 2008, 05:40 PM -0400):
> Matthew Weier O'Phinney <[EMAIL PROTECTED]> wrote:
> 
>     -- David Di Biase <[EMAIL PROTECTED]> wrote
>     (on Friday, 02 May 2008, 04:02 PM -0400):
>     > I'm pretty much a complete noob when it comes to ZF. I've been a
>     procedural PHP
>     > developer for about 1-2 years. I'm dabbling in ZF though right now I
>     think it
>     > best to refrain using the full MVC model in my work. Mostly b/c I don't
>     feel
>     > comfortable with it at the moment.
>     >
>     > So I've gone ahead and attempted to use Zend_Layout without MVC and it
>     appears
>     > that there isn't much useful documentation on it. Which makes it painful
>     for me
>     > to learn :-/
>     >
>     > I most likely have made a mistake/overlooked something but this is what
>     I've
>     > done.
>     >
>     > I've created my configuration include class as such:
>     >
>     >         require_once 'Zend/Layout.php';
>     >         $layout = new Zend_Layout();
>     >         $layout->setLayoutPath("{$_SERVER['DOCUMENT_ROOT']}/layout/")
>     >                   ->setLayout("main");
>     >
>     > I've placed main.phtml in /layout/ and in my index.php scrip I've
>     attempted
>     > echo $layout->render(); but I keep getting this error:
>     >
>     > Fatal error: Class 'Zend_Controller_Action_HelperBroker' not found in /
>     Users/
>     > ddibiase/Documents/workspace/testzend/lib/Zend/Layout.php on line 505
> 
>     What's going on is that Zend_Layout is looking for a view object with
>     which to do its rendering; by default, if none is registered with
>     Zend_Layout, it looks in the ViewRenderer action helper for one... which
>     is where this error is occurring. I'll enter an issue in the tracker to
>     explicitly load the HelperBroker when this happens.
> 
>     For you, what you need to do is create a view object and attach it to
>     your layout object:
> 
>        require_once 'Zend/View.php';
>        $view = new 'Zend/View.php';
>        $layout->setView($view);
> 
>     and you should be good.
> 
> 
> Haha, forgive me but I'm still uber confused. I thought the two lines I have
> there:
> 
>         $layout->setLayoutPath("{$_SERVER['DOCUMENT_ROOT']}/layout/")
>                ->setLayout("main");
> 
> Were meant to first specify a directory of my layout files then setLayout 
> would
> register which view file to use. So if I'm understanding you, instead I have 
> to
> initialise the view and attach it directly?

No, no... You have to attach a view *in addition* to those.

> Oh man. lol. My head is spinning.
> 
> What's the advantage of using layout then? I could just use Zend_View, create
> three objects for my header, footer and content.
> 
> I could probably even just contain the headers in partials for that matter?

When not using the MVC, Zend_Layout doesn't make much sense *except*
that it allows you to register content in placeholders within your other
view scripts *and* specifies a separate directory for the layout view
scripts that supercedes any other view scripts. Other than that, doing
two step views is entirely possible by simply re-using your view object.

Two Step View makes most sense in an application where your content is
being generated in separate processes from your layout -- typically
because your view object goes out of scope. In a procedural script, it
makes less sense.

-- 
Matthew Weier O'Phinney
Software Architect       | [EMAIL PROTECTED]
Zend - The PHP Company   | http://www.zend.com/

Reply via email to