Re: Simple tiny php template

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Stut schreef:
On 22 Aug 2008, at 20:48, Jochem Maas wrote:
Stut schreef:
define('TPL_DIR', dirname(__FILE__).'/tpl/');
function TPL($__filename, $__data = array(), $__return = false)
{
   $__retval = '';
   $__tplfilename = TPL_DIR.$__filename;
   if (file_exists($__tplfilename))
   {
       if ($__return) ob_start();
       extract($__data);
       require($__tplfilename);
       if ($__return)
       {
           $__retval = ob_get_contents();
           ob_end_clean();
       }

else { ob_end_flush(); return; } // I'm guessing this should be in there too

Nope, not even a little bit. The output buffer is only opened if we are returning the output from the template.

feck. your right of course, I was still sleeping I guess :-)


-Stut

   }
   else
   {
       trigger_error('Template not found: '.$__filename, E_USER_ERROR);
   }
   return $__retval;
}
// Example usage
TPL('layout/header.tpl.php', array('title' => 'This is the page title'));
TPL('index.tpl.php');
TPL('layout/footer.tpl.php');
-Stut
On 22 Aug 2008, at 17:26, OOzy Pal wrote:
Hello

Can any one direct to very very tiny simple php template code. I want to use
it for 5-6 pages website.

Thank you

--
OOzy
Ubuntu-Hard



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux