Re: [phplib] path in Template Constructor From: David Nind (David.Nind <email protected>)
Date: 03/19/01

This is what I do:

set area where templates live (have used absolute path here, but not necessary) e.g.
  $t= new Template("/home/httpd/html/testarea/application/templates"

when setting the file array you can include subdirectories under templates e.g.
  $t->set_file(array(
        "mainpage" => "standard/main.tpl",
        "mainmenu" => "standard/menu.tpl"));

Otherwise (from memory) where the templates sit needs to be relative to your files e.g.
  You have: $t = new Template("templates")
                   (actual location /home/httpd/html/testarea/templates)
  Then php script needs to be in the directory below
                   (/home/httpd/html/testarea)
  That's why I include the full path when I setup the template instance, so it doesn't matter where the script is, as long as it is correctly pointing to template location. The only downside is that you have to change the $t = new Template when you move the location of your application.

Hope ths helps.

David

>>> "Iwan Birrer" <iwanbirrer <email protected>> 20/03/01 >>>
Hello,

If I have my files all in the same directory, the Template Class works . But if I move the include Files to another Directory and use something like ($t = new Template("includes") nothing works anymore.

Here are my Files:

-- the php file:--------------------------
<?php
require("template.inc");
$tpl = new Template("templates");
$tpl->set_file("page", "basic_template.inc.html");
$tpl->set_var(array("TITLE" => "This is a Template Test",
     "CONTENTS" => "Hello World!"));
$tpl->parse("out", "page");
$tpl->p("out");
?>

-- the inc file in template/basic_template.inc.html -------
<html>
 <title>{TITLE}</title>
 <body>
  {CONTENTS}
 </body>
</html>

Hope somebody can help me

Thanks

Iwan Birrer

---------------------------------------------------------------------
To unsubscribe, e-mail: phplib-unsubscribe <email protected>
For additional commands, e-mail: phplib-help <email protected>