| ||||||||||
Shopping cart software Solutions for online shops and malls | ||||||||||
|
X-Cart Home | FAQ | Forum rules | Calendar | User manuals | Login |
How to include a PHP file into a .TPL | |||
|
|
Thread Tools | Search this Thread |
#1
|
|||||||
|
|||||||
How to include a PHP file into a .TPL
I have a file called incdist.php with this code:
Code:
This file runs perfect by itself. I have tried to included on a .TPL using this code Code:
It doens't work. Browser keeps running and running.... Nothing is coming out. Any clue????? Dave X-CART PRO 4.0.17 |
|||||||
#2
|
|||||||
|
|||||||
Make sure you include the path to the external php file correctly and use " to surround it instead of '.
__________________
Padraic Ryan Ryan Design Studio Professional E-Commerce Development |
|||||||
#3
|
|||||||
|
|||||||
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 |
|||||||
#4
|
|||||||
|
|||||||
No, you'll need to put it in the skin1 directory.
__________________
Padraic Ryan Ryan Design Studio Professional E-Commerce Development |
|||||||
#5
|
|||||||
|
|||||||
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 |
|||||||
#6
|
|||||||
|
|||||||
Are the permissions set properly?
__________________
Padraic Ryan Ryan Design Studio Professional E-Commerce Development |
|||||||
#7
|
|||||||
|
|||||||
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 |
|||||||
#8
|
|||||||
|
|||||||
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:
Or try using a Smarty include instead: Code:
Then make file incdist.php.tpl your incdist.php file with the {php} and {/php} tags in it. HTH
__________________
Manuka Bay Company X-Cart Version 4.0.19 [Linux] UGG Boots and other fine sheepskin products http://www.snowriver.com |
|||||||
|
|||
X-Cart forums © 2001-2020
|