Guest uplift Posted July 27, 2010 Share Posted July 27, 2010 I've done a google search before posting this, i know it's been covered but all results are as old as 2007 I know i can't include PHP directly in a template but i can assign a variable such as {MY_PHPCODE} and include the code in a separate file or function? Can anyone tell me how to do this? I am trying to add PHP to the viewproduct template. Thanks Quote Link to comment Share on other sites More sharing options...
vokf Posted July 27, 2010 Share Posted July 27, 2010 Please read the documentation project over at cubecartforums.org - that describes the template system, and should help you. Jason Quote Link to comment Share on other sites More sharing options...
Guest Posted July 30, 2010 Share Posted July 30, 2010 Basically every template has a corresponding includes page - viewProd.tpl corresponds to /includes/content/viewProd.inc.php - the tpl has all the html parts, the includes file all the php code and functions. Quote Link to comment Share on other sites More sharing options...
bsmither Posted July 30, 2010 Share Posted July 30, 2010 but i can assign a variable such as {MY_PHPCODE} and include the code in a separate file or function? A direct answer is: you can't. The PHP code in CC uses the XTemplate system to build a string of HTML code and stores that code in a string variable until it gets spit out from the server and sent to your browser. At no time would any part of CC and the XTemplate system "re-digest" the contents of these variables containing the HTML code looking for more PHP code to execute. See if someone might have a different idea about modifying CC over at www.cubecartforums.org. Quote Link to comment Share on other sites More sharing options...
Guest Posted July 30, 2010 Share Posted July 30, 2010 A direct answer is: you can't. Yes you can. I do it all the time and so do mods. As long as you use the correct syntax in the includes file, you can create any custom code you want and call it in the templace as the OP is looking to do. Quote Link to comment Share on other sites More sharing options...
bsmither Posted August 1, 2010 Share Posted August 1, 2010 Sorry, as I read the intent of the OP wanting a work around to make it *seem* like PHP is in the TPL file, that is, run the TPL file itself through the PHP parser. The OP acknowledges that PHP can't exist in the TPL file, and I directly confirmed that. Maybe it was bad phrasing ("I am trying to add PHP to the viewproduct template."). Now, as for mods, there is a discussion just started in the appropriate forums for that. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.