Menu

#35 Template: use include path for set_file

open
nobody
None
5
2002-09-24
2002-09-24
Daniel Ward
No

Allows the use of the include path rather than absolute
or relative filenames in Template::load_file().

Use:
Add the $use_inc_path class variable and replace
Template(), set_file(), and load_file() methods with those
in the attached template.inc.patch file below.

Be sure to add your template directory to your include
path.

Example of use after patch:

$pg = new Template("USE_INC_PATH");
$pg->set_file("filename.tpl");

filename.tpl only needs to be in your include path now
not in current working directory. The same code will
work in any directory this way.

Discussion

  • Daniel Ward

    Daniel Ward - 2002-09-24

    Patch to allow use of include path for Template::load_file()

     
  • Daniel Ward

    Daniel Ward - 2002-09-24

    Logged In: YES
    user_id=598737

    Oops! The new class variable, $use_inc_path, should not be
    set to anything in its declaration. It is set in the new
    constructor. So it should read

    var $use_inc_path;

    rather than

    var $use_inc_path = ".";

    Thats what I get for using copy and paste too much. :o)

     
  • Daniel Ward

    Daniel Ward - 2002-09-24

    Logged In: YES
    user_id=598737

    Also, in my example for use after the patch the second line
    should read

    $pg->set_file("varname", "filename.tpl");

    I'm gonna go get some rest now. :o)

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.