Fwd: Re: [Phplib-users] Using a template as the content of another template.
Brought to you by:
nhruby,
richardarcher
From: Andrew C. <An...@Ev...> - 2002-07-01 20:00:41
|
Well, I sent this last night but, CC'd it to Joe instead of to the list. Too many mailing lists with different defaults for reply-to ... Andrew >Date: Sun, 30 Jun 2002 14:09:15 -0700 >To: Joe Cotellese <jco...@co...> >From: Andrew Crawford <An...@Ev...> >Subject: Re: [Phplib-users] Using a template as the content of another >template. >Cc: Joe Cotellese <jco...@co...> > >Joe, > >Yes. I don't know how standard this is but, I have been working with this >recently in an attempt to get complete separation of form, content, and >function. It helps if you remember that all of the markers (replace items >in {brackets}) and places where blocks have been extracted act like >variables. I don't think it matters whether you extract blocks or load files. > >So, if the main page template (the one with the {content} variable/marker) >is page_template.ihtml, and the form or other stuff you want to fill >{content} with is content_template.ihtml, you would probably want to do >something like this: > > // Start the page template > $t = new Template; > > // set the file to the content template > $t->set_file('some_content', 'content_template.ihtml'); > > // fill in the variables for the content template here > > // parse the completed content area into a variable called content > $t->parse('content', 'some_content'); > > // set the file to the overall page template > $t->set_file('thispage', 'page_template.ihtml'); > > // content is already filled in, set any other variables > // for the page template here > > // parse the finished page into out > $t->parse('out', 'thispage'); > > // output out > $t->p('out'); > >If this is confusing, you might consider looking at: > > http://www.devshed.com/Server_Side/PHP/PHPLib/page1.html > >... and: > > http://www.phpbuilder.com/columns/david20000512.php3 > >Andrew Crawford >An...@Ev... > >At 10:32 AM 6/30/2002 -0400, you wrote: >>Hello, >> >>I just started using PHPLib about a week ago. I really like the template >>feature, it definitely works as advertised. I do however have one >>question that was not immediately evident from the documentation or >>mailing list archives. >> >>Does the PHPLib template system allow one template to be included into >>another template? For example, I have defined an overall site template >>that creates the general layout of my page. The only variable defined is >>{Content}. The idea then is to have Content filled out by information >>from a database or some separate file. This works great, but now I want >>to add a form to the site. Can I replace {Content} with the contents of >>another template that defined the page form or would it be better to >>generate the form programmatically from PHP? >> >>Thanks in advance, >>Joe Cotellese |