SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict
    Join Date
    Jun 2005
    Posts
    286
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to use .tpl files..

    I want to use template files.

    but in my .tpl file the statement {$hello_var} is not executing.

    In my .tpl file I have included a php file with the following code:

    <?php
    $hello_var = "Welcome!";
    ?>
    [COLOR=SlateGray]
    Web Developer @ VeriQual

  2. #2
    SitePoint Addict
    Join Date
    Jul 2007
    Location
    San Jose, California
    Posts
    355
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you including your .tpl file in a php file. If you're not the server doesn't compile the php in the file at all. To have a tpl file with php in working correctly it has to be included in a php file.

  3. #3
    SitePoint Zealot Ken Sharpe's Avatar
    Join Date
    Apr 2008
    Posts
    160
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you have some reason to execute .tpl files as php natively, you can configure your server to treat certain files as php.

  4. #4
    SitePoint Member rupam_jaiswal's Avatar
    Join Date
    Jun 2006
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use
    require "/path/to/smarty/Smarty.class.php";
    $sm = new Smarty;
    $sm->template_dir = './templates';
    $sm->compile_dir = './templates_c';
    $sm->compile_check = true;
    save the above code in smartINC.php and include this in your php file.
    create 2 folders i,e templates and templates_c.
    in php file

    <?php
    $hello_var = "Welcome!";
    $sm->assign("hello_var",$hello_var);
    $sm->display('Your tpl.tpl');
    ?>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •