Yeah, well I guess I'm trying to break away from procedural while not
foraying 100% into MVC. I'm trying to keep the code dry (a new term I just
learned :-p) regardless.
My next question is, how am I to understand the usage of head helpers and
all the other goodies for adding <link> values into my head? I'd really like
to learn these!
What I'm thinking is that...perhaps I can set default head values but in my
page content views I want to pass detail from the view to modify the head.
For example, I like to split off my CSS files per script (usually). For
example I'll have a global.css for standard templates, then for page
specific stuff I'll do something like register.css etc. What I'd like to do
is include in register.phtml a directive of some sort to change the layout
head to add <link> in automatically.
If I can't do it via the register.phtml view script then most likely I'll
have to do it in my own controller script.
My question is how do I do this for either of them? This is what I mean
about using them as standalone tools, there really isn't any direction
unless I dig deep into the code and spend more time learning how to do them.
The question I have also is, what are the disadvantages of using Zend_View
and Zend_Layout as opposed to regular procedural coding? heh.
Sorry for the, somewhat, silly questions. You guys know these answers most
likely but really I have no clue and don't know how to acquire the answers!
David
On Sat, May 3, 2008 at 9:58 AM, Matthew Weier O'Phinney <[EMAIL PROTECTED]>
wrote:
> -- 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/
>
--
David Di Biase