How to add a PHP include to a Page?

I’m wanting to add a php include to a page on my site, but can’t get it to work.

I create the page, switch to code view (or HTML view), add the code and Save. But my include doesn’t work and when I go back to check out the HTML, the editor has added <–! to the beginning and → to the end of the include code, thus changing it to be a comment instead of an include to be executed.

Anyone know how to fix this?

I think the editor is the problem, add source without editor and see what is happening…

Thanks for the response.

I didn't know I could add source code without an editor… How do I do that?

Read up on {php} | Smarty

Triplets, I don't think I'm any the wiser after reading that, but thanks anyway!

Try reading it again. It clearly tells one how to add php code to a smarty template (.tpl file). Cs-cart uses the smarty template engine.

I'm not trying to add code to the .tpl file, because that would change every page that uses that template…right? I want to use a PHP include on one page by putting it in the HTML box on a CMS page, but it won't let me because it changes the code I insert.

the html page can be viewed as source, just dont click the edit in html button, put your code in there. But not sure if PHP works in it.

[quote name='johnbol1' timestamp='1311353054' post='118001']

the html page can be viewed as source



Not sure If I am on the wrong track as Im no coder, but would you have to use literal tags?


I'm not a coder either, and I don't know what literal tags are. All I want to do is to add a PHP include to one page on my site. I go to Website>Content>Add Page, then in the “Description” box I add code like this:

my include here

but when I save the page the CMS has changed the code and it doesn't work.


What version are you using? If you upgraded from 2.1.4 to 2.2.1 you should have this line in your config.local.php

$config["tweaks"]["allow_php_in_templates"] = false; // Allow to use {php} tags in templates

I know that for one of Webgraphiq's addons that has to be changed to true so maybe you might need to do the same?

Hope that helps,


I'm on 2.2.1.

Thanks Brandon. I will try that and let you know what happens.

OK I have tried that now, but the results are the same. I create the page with the include code, but