2015-09-28 73 views
-3

我想包括PHP文件到TPL文件 我的代碼:我的文件無法讀取智者

/**{include_php file='Compteur.php'}**/ 

Smarty的SH

Notice: Undefined property: SmartyBC::$trusted_dir in /var/www/vhosts/vps143526.ovh.net/my-wall.fr/dev/tools/smarty/Smarty.class.php on line 730

Fatal error: Uncaught --> Smarty Compiler: Syntax error in template "/var/www/vhosts/vps143526.ovh.net/my-wall.fr/dev/modules/admincreation/admincreation.tpl" on line 58"{include_php file='Compteur.php'}"{include_php} file 'Compteur.php' is not readable <-- thrown in /var/www/vhosts/vps143526.ovh.net/my-wall.fr/dev/tools/smarty/sysplugins/smarty_internal_templatecompilerbase.php on line 58

我怎樣才能解決這個問題呢? 在此先感謝

+0

這可能是很多事情,你的文件不存在,它的路徑是無效的,你的文件是讀鎖定,損壞或不符合一些Smarty要求被讀取(像這個'SmartyBC :: $ trusted_dir'這似乎是未設置的,但需要獲得價值)。根據您提供的信息,您必須爲每個人進行調試,除非您有更多要分享的內容。 –

回答

0

我不得不做出另一種解決方案至極是直接我.tpl頁

{php} 
$monfichier = fopen('{$modules_dir}Compteur.txt', 'r+'); 
$pages_vues = fgets($monfichier); 
$pages_vues++; 
fseek($monfichier, 0); 
fputs($monfichier, $pages_vues); 
fclose($monfichier); 
echo '<p>Cette page a été vue ' . $pages_vues . ' fois !</p>'; 
{/php} 

中插入代碼,但我得到了另外一個問題:

Warning: fopen(): open_basedir restriction in effect. File(/dev/modules/Compteur.txt) is not within the allowed path(s): (/var/www/vhosts/vps143526.ovh.net/:/tmp/) in /var/www/vhosts/vps143526.ovh.net/my-wall.fr/dev/tools/smarty/SmartyBC.class.php(464) : eval()'d code on line I know its related to permissions, I have change it to "777" but the error is still here

+0

請不要使用答案區域放置屬於您問題的代碼。你已經完成了你的大部分問題。如果您還有其他問題,請問另一個問題,而不是發佈針對相同問題的其他問題。 –

0

在模板引擎,使用PHP文件到實例變量。控制器在Prestashop。