2014-06-16 51 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