Re: Beginner to HTML_Template_Flexy

From: Date: Fri, 14 Jan 2005 10:24:58 +0000
Subject: Re: Beginner to HTML_Template_Flexy
References: 1 2  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-16932@lists.php.net to get a copy of this message
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::bufferedOutputObject($object) returns a string instead of outputting it.
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. 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

« previous php.pear.general (#16932) next »