Home > Archive > PHP Pear > January 2005 > Re: [PEAR] Beginner to HTML_Template_Flexy
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Re: [PEAR] Beginner to HTML_Template_Flexy
|
|
| daniel@electroteque.org 2005-01-13, 3:57 am |
| It works differently to normal block based engines. What I do is compile
the template u wantinside a function or method , and then call that method inside the main
template. I know there is away to compile to a string rather than outputting it but never tried it yet.
> Hi Everyone, I am very new to PEAR and I am trying to use the Flexy
> templating engine. I would appreciate any help provided.
>
> What I am trying to do is create a website based on templates using
> Flexy. My site will have different sections and each section will use
> the same basic page layout. However, each section could have different
> content in the sidebar, the footer, menu area, etc.
>
> I need Flexy to load the main template of my site and then based on the
> different sections, to load each section's content based on the folder
> location. For example, if I am on the "Profiles" section, then I want
> the sidebar.inc, menu.inc, footer.inc to load from the
> /templates/profile/ folder. This should happen ONLY if those files
> exist. If any of those includes do not exist, then the default
> sidebar.inc, menu.inc and footer.inc should be loaded from the parent
> /templates/ folder.
>
> The problem I am having right now is.. within my main template file, I
> am trying to the php include call to include the different sections,
> but it seems like Flexy is totally ignoring the include calls. How do I
> make one template include another template in flexy?
>
> thank you,
> ramin
>
> --
> PEAR General Mailing List (http://pear.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
| |
| Daniel García 2005-01-14, 3:58 pm |
| daniel@electroteque.org wrote:
>It works differently to normal block based engines. What I do is compile
>the template u wantinside a function or method , and then call that method inside the main
>template. I know there is away to compile to a string rather than outputting it but never tried it yet.
>
>
Method HTML_Template_Flexy::bufferedOutputObjec
t($object) returns a
string instead of outputting it.
[color=darkred]
I use something like this:
mainTemplate.html
<html>
<div class="sidebar">{getSideBar():h}</div>
<div class="mainContents">{mainContents:h}</div>
<div class="footer">{getFooter():h}</div>
</html>
Then, in the controller class (say, page.class.php):
class page {
var $mainContents;
....
function renderPage() {
$flexy = new HTML_Template_Flexy();
$flexy->compile("mainTemplate.html");
$flexy->outputObject($this);
}
function getSideBar() {
If there is a sideBar template in the section directory, then
$template = $templateFromSectionDir
else
$template = $templateFromDefaultDir
$flexy = new HTML_Template_Flexy();
$flexy->compile($template);
$flexy->outputObject($object);
// or also $html = $flexy->bufferedOutputObject($object); return
$html;
}
function getFooter() {...}
.....
}
-- Daniel
|
|
|
|
|