davidolson Posted December 28, 2014 Share Posted December 28, 2014 Why smarty won't find my template file? Fatal error: Uncaught --> Smarty: Unable to load template file 'test.tpl' <-- thrown in C:\xampp\htdocs\testing\includes\smarty\sysplugins\smarty_internal_templatebase.php on line 129 also did testinstall $smarty->testInstall(); Smarty Installation test... Testing template directory... C:\xampp\htdocs\testing\templates\frontend\default\tpl is OK. Testing compile directory... C:\xampp\htdocs\testing\templates_c\frontend is OK. Testing plugins directory... C:\xampp\htdocs\testing\includes\smarty\plugins is OK. Testing cache directory... C:\xampp\htdocs\testing\cache is OK. Testing configs directory... C:\xampp\htdocs\testing\configs is OK. Testing sysplugin files... ... OK Testing plugin files... ... OK Tests complete. And get template dir var_dump($smarty->getTemplateDir()); array(1) { [0]=> string(55) "C:/xampp/htdocs/testing/templates/frontend/default/tpl\" } File schema htdocs -- testing -- incluses -- smarty plugins sysplugins Smarty.class.php SmartyBC.class.php -- configs configs.php -- db connect.php db.php -- configs -- cache -- templates -- frontend -- default -- css -- mages -- js -- tpl test.tpl -- backend -- templates_c -- frontend index.php index.php <?php ini_set('display_errors', 1); ini_set('log_errors', 1); ini_set('display_startup_errors', TRUE); ini_set('error_log', dirname(__FILE__) . '/error_log.txt'); error_reporting(E_ALL); ob_start(); session_start(); require 'includes/smarty/Smarty.class.php'; require 'includes/db/db.php'; require 'includes/configs/configs.php'; $page = isset($_GET['do']) ? $_GET['do'] : ''; switch($page){ case 'home'; include 'pages/home.php'; break; default: include 'pages/test.php'; break; } ob_flush(); ?> configs.php <?php $smarty = new Smarty(); $smarty->compile_check = true; $smarty->debugging = false; $smarty->cache = 1; $smarty->setTemplateDir('C:/xampp/htdocs/testing/templates/frontend/default/tpl'); $smarty->setCompileDir('C:/xampp/htdocs/testing/templates_c/frontend/default'); $smarty->setCacheDir('C:/xampp/htdocs/testing/cache'); $smarty->setConfigDir('C:/xampp/htdocs/testing/configs'); ?> test.php <?php //$success = 'Success Message'; //$error = 'Error Message'; $errors[] = 'Error one'; $errors[] = 'Error two'; $smarty = new Smarty; //$smarty->assign('success', $success); //$smarty->assign('error', $error); $smarty->assign('errors', $errors); $smarty->display('test.tpl'); ?> test.tpl {if !empty($errors)} <div id="errors"> {section name=i loop=$errors} {$errors[i]}<br /> {/section} </div> {/if} Quote Link to comment https://forums.phpfreaks.com/topic/293458-why-smarty-wont-find-my-template-file/ Share on other sites More sharing options...
CroNiX Posted December 29, 2014 Share Posted December 29, 2014 Just a guess here, but are you sure the file is located in the sysplugins dir? Your testInstall() indicates the dir is named "sysplugin". Quote Link to comment https://forums.phpfreaks.com/topic/293458-why-smarty-wont-find-my-template-file/#findComment-1501092 Share on other sites More sharing options...
bsmither Posted December 30, 2014 Share Posted December 30, 2014 In what file is this statement? var_dump($smarty->getTemplateDir()); My guess: in test.php, there is a new instantiation of Smarty in $smarty, quite possibly overwriting the previously existing instantiation of Smarty in $smarty from config.php. Quote Link to comment https://forums.phpfreaks.com/topic/293458-why-smarty-wont-find-my-template-file/#findComment-1501098 Share on other sites More sharing options...
Solution davidolson Posted January 4, 2015 Author Solution Share Posted January 4, 2015 My guess: in test.php, there is a new instantiation of Smarty in $smarty, quite possibly overwriting the previously existing instantiation of Smarty in $smarty from config.php. Jep. Thats the problem Quote Link to comment https://forums.phpfreaks.com/topic/293458-why-smarty-wont-find-my-template-file/#findComment-1501717 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.