Theo13 Posted August 11, 2014 Share Posted August 11, 2014 Hello, I'm creating a module on Prestashop, and I have a really basic question. I have a TPL file, in which I get a JavaScript object when the users clicks on a button. I want to get this Object in PHP to create a new Prestashop article with the informations of this Object. But I know it is wrong to call PHP inside of a TPL file. Is my architecture wrong? Is there some option to call my PHP function with this Object as a parameter when I click on my button? Any help would be really appreciated! Thanks! Link to comment Share on other sites More sharing options...
vekia Posted August 11, 2014 Share Posted August 11, 2014 hello javascripts will not work in php in tpl file you need to create <form> with <input type submit> button then, in module php controller you will be able to get variables from <form> as a $_POST array (via Tools::getValue('Param') function) Link to comment Share on other sites More sharing options...
Theo13 Posted August 11, 2014 Author Share Posted August 11, 2014 Okay, I understand how to do that. But how do I call the specific function of my module I want when clicking on the submit button? Link to comment Share on other sites More sharing options...
Eolia Posted August 12, 2014 Share Posted August 12, 2014 Okay, I understand how to do that. But how do I call the specific function of my module I want when clicking on the submit button? in your module file, in your hook function, if the input name is "your_value": public function hookDisplayYourContent($params) { $your_value = Tools::getValue('your_value') if(!empty($your_value) { //do something.... } } or use ajax in your tpl... Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now