|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
addykha Smarty Rookie
Joined: 20 Nov 2011 Posts: 6
|
Posted: Sun Nov 20, 2011 1:26 pm Post subject: i always get an error. pls help |
|
|
this is the error i always got.
Fatal error: Uncaught exception 'SmartyException' with message 'Unable to load template file 'index.tpl'' in C:\xampp\smarty\libs\sysplugins\smarty_internal_templatebase.php:127 Stack trace: #0 C:\xampp\smarty\libs\sysplugins\smarty_internal_templatebase.php(362): Smarty_Internal_TemplateBase->fetch('index.tpl', NULL, NULL, NULL, true) #1 C:\xampp\htdocs\smarty\index.php(14): Smarty_Internal_TemplateBase->display('index.tpl') #2 {main} thrown in C:\xampp\smarty\libs\sysplugins\smarty_internal_templatebase.php on line 127
I followed the installation instructions in this site.
http://memohnish.wordpress.com/2009/05/19/smarty-installation-on-wamp-and-xampp/
Pls i really need some help [/i] |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Sun Nov 20, 2011 3:11 pm Post subject: |
|
|
Those instructions are for Smarty 2, Smarty 3 has setters/getters for setting your template directories. Follow the install instructions for Smarty from the Smarty manual.
$smarty->setTemplateDir('C:/xampp/htdocs/smarty/templates’); |
|
Back to top |
|
addykha Smarty Rookie
Joined: 20 Nov 2011 Posts: 6
|
Posted: Sun Nov 20, 2011 3:38 pm Post subject: |
|
|
i'll try it. thanks |
|
Back to top |
|
addykha Smarty Rookie
Joined: 20 Nov 2011 Posts: 6
|
Posted: Sun Nov 20, 2011 3:58 pm Post subject: |
|
|
i have tried this code but still there's an error
Code: | <?php
/**
* Example Application
* @package Example-application
*/
define('SMARTY_DIR', 'C:/xampp/smarty/libs/');
require SMARTY_DIR.'Smarty.class.php';
$smarty = new Smarty;
$smarty->testInstall();
$smarty->setTemplateDir('http://localhost/templates');
$smarty->setCompileDir('http://localhost/templates_c');
$smarty->setCacheDir('http://localhost/cache');
$smarty->setConfigDir('http://localhost/smarty/configs');
$smarty = new Smarty;
//$smarty->force_compile = true;
$smarty->debugging = true;
$smarty->caching = true;
$smarty->cache_lifetime = 120;
$smarty->assign("Name","Fred Irving Johnathan Bradley Peppergill",true);
$smarty->assign("FirstName",array("John","Mary","James","Henry"));
$smarty->assign("LastName",array("Doe","Smith","Johnson","Case"));
$smarty->assign("Class",array(array("A","B","C","D"), array("E", "F", "G", "H"),
array("I", "J", "K", "L"), array("M", "N", "O", "P")));
$smarty->assign("contacts", array(array("phone" => "1", "fax" => "2", "cell" => "3"),
array("phone" => "555-4444", "fax" => "555-3333", "cell" => "760-1234")));
$smarty->assign("option_values", array("NY","NE","KS","IA","OK","TX"));
$smarty->assign("option_output", array("New York","Nebraska","Kansas","Iowa","Oklahoma","Texas"));
$smarty->assign("option_selected", "NE");
$smarty->display('index.tpl');
?>
|
this is the error showed up
Smarty Installation test...
Testing template directory...
C:\xampp\htdocs\smarty\templates is OK.
Testing compile directory...
C:\xampp\htdocs\smarty\templates_c is OK.
Testing plugins directory...
C:\xampp\smarty\libs\plugins is OK.
Testing cache directory...
C:\xampp\htdocs\smarty\cache is OK.
Testing configs directory...
C:\xampp\htdocs\smarty\configs is OK.
Testing sysplugin files...
... OK
Testing plugin files...
... OK
Tests complete.
Fatal error: Uncaught exception 'SmartyException' with message 'Unable to load template file 'index.tpl'' in C:\xampp\smarty\libs\sysplugins\smarty_internal_templatebase.php:127 Stack trace: #0 C:\xampp\smarty\libs\sysplugins\smarty_internal_templatebase.php(362): Smarty_Internal_TemplateBase->fetch('index.tpl', NULL, NULL, NULL, true) #1 C:\xampp\htdocs\smarty\index.php(39): Smarty_Internal_TemplateBase->display('index.tpl') #2 {main} thrown in C:\xampp\smarty\libs\sysplugins\smarty_internal_templatebase.php on line 127
what's the problem here? |
|
Back to top |
|
addykha Smarty Rookie
Joined: 20 Nov 2011 Posts: 6
|
Posted: Sun Nov 20, 2011 4:21 pm Post subject: |
|
|
i tried another code
setup.php
Code: | <?php
require('Smarty.class.php');
class Smarty_cti extends Smarty
{
function __construct()
{
parent::__construct();
$this->setTemplateDir( 'C:/xampp/htdocs/smarty/templates');
$this->setCompileDir( 'C:/xampp/htdocs/smarty/templates_c');
$this->setConfigDir( 'C:/xampp/htdocs/smarty/configs');
$this->setCacheDir('C:/xampp/htdocs/smarty/cache');
//$this->caching = true;
$this->assign('app_name', 'cti');
}
}
?> |
index.php
Code: | <?php
require('setup.php');
$smarty = new Smarty_cti();
$smarty->assign('name', 'Adrian');
$smarty->display('index.tpl');
?> |
but still, the same error shows up. |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Sun Nov 20, 2011 4:22 pm Post subject: |
|
|
Quote: | $smarty->setTemplateDir('http://localhost/templates');
$smarty->setCompileDir('http://localhost/templates_c');
$smarty->setCacheDir('http://localhost/cache');
$smarty->setConfigDir('http://localhost/smarty/configs');
|
Url's do not work here. You must use a relative or absolute filepath here.
Also you should run testInstall() after you have configured the directories. |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Sun Nov 20, 2011 4:26 pm Post subject: |
|
|
Is index.tpl now in your 'C:/xampp/htdocs/smarty/templates' folder? |
|
Back to top |
|
addykha Smarty Rookie
Joined: 20 Nov 2011 Posts: 6
|
Posted: Sun Nov 20, 2011 4:34 pm Post subject: |
|
|
yes it is. |
|
Back to top |
|
addykha Smarty Rookie
Joined: 20 Nov 2011 Posts: 6
|
Posted: Sun Nov 20, 2011 4:53 pm Post subject: |
|
|
it's working now. thanks! |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Sun Nov 20, 2011 4:54 pm Post subject: |
|
|
what was the problem? |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|
|