-- 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.
<snip>
> I'm also wondering as a second part that now I'm able to render the layout, I
> also want to include parts into the content and nav sections. Furthermore I
> want to do this via Zend_View. From what I read in the documentation I can use
> layout to initiate a view specific for my current page. So I'm assuming that I
> create the view and then before I render and echo out the full layout I set
> the
> ->content value with my view render like this:
>
> $layout->content = $view->render();
>
> Does this make sense? Have I understand it properly?
Yes, that works. :-)
> I would love to just read documentation and do this myself, but all of
> the ZF work seems to be tightly connected to MVC. :-/
Feel free to write up an example for inclusion to the documentation. :-)
While Zend_Layout was designed such that it can be used without the MVC,
the focus was on using it *with* it, so docs supporting non-MVC use
cases were not a priority. If you'd like to help with the effort, please
submit your CLA, and we'll get you setup to contribute. :-)
--
Matthew Weier O'Phinney
Software Architect | [EMAIL PROTECTED]
Zend - The PHP Company | http://www.zend.com/