![]() |
How to include a PHP file into a .TPL
I have a file called incdist.php with this code:
Code:
<?php This file runs perfect by itself. I have tried to included on a .TPL using this code Code:
{php} It doens't work. Browser keeps running and running.... Nothing is coming out. Any clue????? Dave X-CART PRO 4.0.17 |
Make sure you include the path to the external php file correctly and use " to surround it instead of '.
|
The TPL file is on /skin1/customer/main/dist.tpl
and the php is on /incdist.php is that the correct path? Thanks Dave X-CART PRO 4.0.17 |
No, you'll need to put it in the skin1 directory.
|
Now I get this errors:
Warning: Smarty error: file:incdist.php is not readable in /www/www.domain.com/xcart/Smarty-2.6.9/Smarty.class.php on line 1088 Warning: _include(): Failed opening '' for inclusion (include_path='/www/www.domain.com/xcart/modules/Special_Offers:/www/www.2tmoto.com/xcart/include/template in /www/www.2tmoto.com/xcart/Smarty-2.6.9/Smarty.class.php on line 1915 I am totally lost.... We are migrating pages from our old store to xcart, and we have problems with all php pages. Thanks Dave X-CART PRO 4.0.17 |
Are the permissions set properly?
|
File permissions are set as any other file.
What am I doing wrong? I just want to insert a php file in a template. It is possible, isn't it? Thanks, Dave X-CART PRO 4.0.17 |
The error is showing that you probably don't have your file in any directory on the include path. This is a little confusing because you are trying to do something in a way Smarty never intended it to be done. To do it the Smarty way you should be modifiying one of the X-Cart PHP files to get the data from the DB and make it available to the Smarty template and using the template to generate the HTML.
That said, I think the root of the problem doing it your way is that using the Smarty PHP tag is using the include path available at template execution time not at template compile time like a Smarty include. There are two things you can try. Specify the full path like this: Code:
{php} Or try using a Smarty include instead: Code:
{include file="incdist.php.tpl"} Then make file incdist.php.tpl your incdist.php file with the {php} and {/php} tags in it. HTH |
All times are GMT -8. The time now is 01:20 PM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.