I am at a begginer level with cs-cart coding. I have the output I want in raw format (outputs some strings and links), but are stuck on the next step
Q1. How do I now display my output within a cs-cart frame/page?
This is how my solution works so far
- I have created a page (using the admin panel menu) with a input box
- I have a php file in the root of the store that takes the $Pist input box, makes some API calls and returns an array of results
- using basic php/html tags I have a set of vairables I want to display
Q2. Also is it wrong to go about a solution this way, I know the solution is personalised to my store, and it isn’t an add-on but I don’t want to commercialise it so I think that is ok? i.e. as long as I prevent sql injection there isn’t a security risk and if I am not doing PUTs I am not going to break anything?
Thanks for the input. I don’t think I have broken any of the listed standards. I am simply using API calls to get data and then manipulating it (but not modifying/PUTing it), what suggests I might have not followed any of those links (and I will go back and have another look, not that I am selling it, but good to learn right from the start!).
My PHP file is called from a submit action from a form using the inbuilt menu/capabilities … so don’t think anything wrong their either?
So how do I follow your advice and use a smarty to display the content (I know how to add a html/smarty block to layout) … could you give me an example based on if I had created a vairable $my_test_variable in my php file how would I display that? does it have to be on the same page where the form called the php file? … or is this where the standards start to become an issue i.e. you can’t get back into cs-cart ‘legitimately’ without an add-on?
Speaking of add-ons, for example it won’t be possible to provide such a solution at the CS-Cart Add-on Market, since your solution (if it is not a service) must have a package with your add-on.
In this case, I recommend starting with these tutorials, which will introduce you to the wonderful world of CS-Cart add-ons.
You still haven’t answered either question and twice addressed a question I didn’t ask (I have said I don’t want ot sell it). But thanks for having a crack at it.
Oh, sorry, I read it in the wrong way. Instead of
I have read
I want to commercialise it so I think that is ok?
Forgive me for my blindness
In case you will use the separate script, you need to do the following:
- Make sure that your script connects to the installation itself. This can be achieved by including the following code in the beginning of your script:
require(dirname(__FILE__) . '/init.php');
- Once all the necessary data is processed and is ready to be displayed, you can now to put it into the Smarty variable:
variable_name will be the name of the variable that can be used in the Smarty template.
- Than, since all the code is located within one separate script (not as separate controller within an add-on), you can manually display the template:
views/auth/popup_login_form.tpl is the relative path to the template from the design/themes/[active_theme_name]/templates/ folder.
- Create the template, which path you have specified in the 3rd step. There you will be able to use all the variables you have assigned in the 2nd step. Information on Smarty syntax can be found here:
MANY thanks for this @CS-Cart_team!