0
votes

Fatal error:Uncaught--Smarty:Unable to load template file 'H.tpl'<--thrown in C:\wamp\www\Smarty\libs\sysplugins\smarty_internal_templatebase.php on line127

Hello , When i try to run a smarty program then i face this fetal error . I don't know how to remove this error. I create two files, one for .php and another for .tpl

PHP File : HelloWorld.php

//This is a simple comment use in php file 

require './libs/Smarty.class.php';//require function  includes Smarty class  
require 'demo/templates/H.tpl';

$smarty=new Smarty;// instantiates an object $smarty of class Smarty


$smarty->caching =true;//enable the caching  

$smarty->assign ('name', 'hello world');//used to assign values to the templates

$smarty->display ('H.tpl');//this is used to display the template

?>

TPL File : H.tpl

<html>

<head>

  <title>My first Smarty program</title>

</head>

<body>

  {*This is a comment line of smarty *}

  {$name}{*Smarty will replace the assigned content *}

</body>

</html>
1
It's saying it can't find H.tpl - check your paths and that the file exists, is readable by PHP, etc. etc. etc. - Lee S
You must configure template dir before using smarty - baldrs
By default smarty templates are in templates dir. So you should place file H.tpl into this directory - Marcin Nabiałek
Have you created templates_c? Write permission for this folder? - Butterfly

1 Answers

0
votes

You should not do:

require 'demo/templates/H.tpl';

at all because it's not PHP file.

When you want to display tpl file you simple do:

$smarty->display ('H.tpl');

or in tpl file you may include other files using

{include file="info.tpl"}

But you dont' have to and cannot include those files in pure PHP

And if your file HelloWorld.php is in main directory, file H.tpl should be placed in templates directory not in demo/templates directory.