2014-06-16 52 views
0

我安装并配置了XAMPP。我正在尝试安装Smarty 3.1.18,我遇到了一些问题。Windows 8.1 XAMPP和smarty

我已更改我的php.ini文件以将smarty/libs目录添加到includes。 我解压到的Smarty我c:\smarty文件夹 我做了我smarty\templatesconfig文件夹中htdocs文件夹 我还做了我的缓存和c:\smarty文件夹内的文件夹templates_c。 我使我的index.php文件包含所有目录,并将我的index.tpl文件放入我的模板文件夹中。 当我运行index.php文件,我回到这一点:

Fatal error: Uncaught --> Smarty: Unable to load template file 'index.tpl' <-- thrown in C:\smarty\libs\sysplugins\smarty_internal_templatebase.php on line 127

任何想法?

我已运行testinstall()脚本,这是它返回:

Smarty Installation test... 
Testing template directory... 
FAILED: .\templates\ does not exist. 
Testing compile directory... 
FAILED: .\templates_c\ does not exist. 
Testing plugins directory... 
C:\smarty\libs\plugins is OK. 
Testing cache directory... 
FAILED: .\cache\ does not exist. 
Testing configs directory... 
FAILED: .\configs\ does not exist. 
Testing sysplugin files... 
... OK 
Testing plugin files... 
... OK 
Tests complete. 

我检查和复查我的文件位置和目录位置,这是他们在哪里:

$smarty->template_dir = 'c:/xampp/htdocs/smarty/templates'; 
$smarty->config_dir = ' c:/xampp/htdocs/smarty/config'; 
$smarty->cache_dir = 'c:/smarty/cache'; 
$smarty->compile_dir = 'c:/smarty/templates_c'; 
+1

请提供您的代码如何设置模板目录为您Smarty类 –

+0

确定何人编辑我的问题,现在没有任何意义...... – TedEBare1970

回答

1

你应该做的是使用以下方法设置模板,templates_c,缓存和配置的正确路径:

$smarty->setTemplateDir('full_xampp_project_path/templates'); 
$smarty->setCompileDir('c:\smarty\templates_c'); 
$smarty->setConfigDir('full_xampp_project_path/config'); 
$smarty->setCacheDir('c:\smarty\cache'); 
0/XAMPP/htdocs中/ yourproject`您需要手动设置这些目录:

由于full_xampp_project_path何至于在c:\smarty你解压智者和你的项目中,例如C您的项目中,例如c:/xampp/htdocs/yourproject

你应该提供完整路径。

你应该确保你的所有路径确实存在。

编辑

我刚刚测试了类似的配置,但因为它其实没有必要也没有在php.ini改变任何东西。我把Smarty放入c:\smarty并在那里创建templates_c anc cache目录,我也有templatesconfigs目录在我的web服务器的目录里面。

我使用下面的代码:

<?php 

require 'c:\smarty\Smarty.class.php'; 

$smarty = new Smarty; 
$smarty->setTemplateDir('D:\DaneAplikacji\WampServer\www\smarty\demo\templates'); 
$smarty->setCompileDir('C:\smarty\templates_c'); 
$smarty->setConfigDir('D:\DaneAplikacji\WampServer\www\smarty\demo\configs'); 
$smarty->setCacheDir('C:\smarty\cache'); 

$smarty->testInstall(); 
$smarty->display('demo.tpl'); 

,一切工作正常。输出是:

Smarty Installation test... 
Testing template directory... 
D:\DaneAplikacji\WampServer\www\smarty\demo\templates is OK. 
Testing compile directory... 
C:\smarty\templates_c is OK. 
Testing plugins directory... 
C:\smarty\plugins is OK. 
Testing cache directory... 
C:\smarty\cache is OK. 
Testing configs directory... 
D:\DaneAplikacji\WampServer\www\smarty\demo\configs is OK. 
Testing sysplugin files... 
... OK 
Testing plugin files... 
... OK 
Tests complete. 

demo 

所以一切正常,因为它应该。你应该简单地使用我上面描述的方法来设置目录并确保这些目录存在。

+0

你好, 公告:未定义指数:名称在C:\ XAMPP \智者\ templates_c \ 5afa44c5bb5ef66ed311d96647082148d7699422.file.demo.tpl。php 28行 注意:试图获取非对象的属性在C:\ xampp \ smarty \ templates_c \ 5afa44c5bb5ef66ed311d96647082148d7699422.file.demo.tpl.php在第28行 – TedEBare1970

+0

这就是我得到的回报。 – TedEBare1970

+0

我想出了问题所在。使用你的一些代码行,并制作一个简单的demo.tpl文件,我就可以工作了。感谢你的知识和时间。 – TedEBare1970