violinman Posted June 15, 2017 Share Posted June 15, 2017 I need to put some php code into a site document, do I just add it or does it need to be enclosed in certain tags. Many thanks, Brian Quote Link to comment Share on other sites More sharing options...
Noodleman Posted June 15, 2017 Share Posted June 15, 2017 it depends on the code, you can normally do what you want using smarty rather than directy PHP. Enable parse smarty tags for your document. Quote Link to comment Share on other sites More sharing options...
violinman Posted June 15, 2017 Author Share Posted June 15, 2017 Thanks for your reply, is that the "Parse Smarty Tags" tick box? then presumably I need to learn a bit of Smarty to know which tags to use. Quote Link to comment Share on other sites More sharing options...
Noodleman Posted June 15, 2017 Share Posted June 15, 2017 smarty is PHP, but written a little differently. what is the code you need to add and why do you need to add it? Quote Link to comment Share on other sites More sharing options...
violinman Posted June 15, 2017 Author Share Posted June 15, 2017 This is the code, it is a much more sophisticated contact form that I have been using on my old site. <?php $contact_form = 1; // set desired form number. $contact_form_path = '/var/www/vhosts/mysite.com/httpdocs/contact-files/'; // set path to /contact-files/ with slash on end. require $contact_form_path . 'contact-form-run.php'; ?> Thank you. Quote Link to comment Share on other sites More sharing options...
Noodleman Posted June 15, 2017 Share Posted June 15, 2017 You are probably going to need to have that PHP code output to a smarty variable using a code snippit or hook. You can merge the contact-form-run.php file contents with your PHP code. Then, all you need in your document is the smarty variable, something like {$MY_VARIABLE} The complexity really depends on what is in your PHP files you are including. Quote Link to comment Share on other sites More sharing options...
violinman Posted June 15, 2017 Author Share Posted June 15, 2017 Thanks for your help, that is probably beyond my capabilities. I was not absolutely sure what you were suggesting. I am not a programmer so I do not know how to output a smarty variable to a hook or snippet. Brian Quote Link to comment Share on other sites More sharing options...
bsmither Posted June 16, 2017 Share Posted June 16, 2017 Putting PHP code in a Document, a product's Description, or a category's Description is nearly impossible. The text is treated by CubeCart as a value to assign to a variable. This variable and assigned text value never sees anything that could execute embedded PHP code. As mentioned by Noodleman, there is a way by using hooks to get the results of what you may be wanting. Feel free to send me a PM if you want to learn how to do this. Quote Link to comment Share on other sites More sharing options...
Noodleman Posted June 16, 2017 Share Posted June 16, 2017 For reference: https://support.cubecart.com/index.php?/Knowledgebase/Article/View/203/46/how-can-i-create-a-plugin-using-the-code-hooks-system-in-cubecart-v5 The concept is pretty much the same for a snippit, although you just paste your code rather than build a module Quote Link to comment Share on other sites More sharing options...
violinman Posted June 17, 2017 Author Share Posted June 17, 2017 Hi Noodleman, I have printed out the article in question, it is certainly something I do need to learn how to do but it will be a week or two before I have time to have a go at it. For now I have saved a live CubeCart page as a static page and are making the alterations I need in there. Thanks for everyones advice. Brian 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.