prestashop_newuser Posted December 30, 2014 Share Posted December 30, 2014 I am doing a small module in Prestashop. In that module I have taken some variables and want that variables to use in smarty template. My code for module goes like this class MyModule extends Module {public $settings = array();public function __construct(){$this->name = 'mymodule';$this->tab = 'front_office_features';$this->version = '1.0.0';$this->author = 'myname';$this->need_instance = 0;$this->bootstrap = 'true';parent::__construct();$this->displayName = $this->l('my module');}public function install(){if(!parent::install() || !$this->registerHook('top') || !$this->registerHook('header')|| !$this->registerHook('displayHome') || !$this->registerHook('displayMobileTopSiteMap'))return false;return true;}public function uninstall(){if(!parent::uninstall())return false;return true;}public function getContent() {$this->_html = '';$input_var1 = Tools::getValue('input1');$input_var2 = Tools::getValue('input2');$input_var3 = Tools::getValue('input3');array_push($settings,$input_var1, $input_var2, $input_var3)$this->_html .= $this->renderForm();return $this->_html;}public function displaySettings() {global $cookie;var_dump($this->settings);return $this->display(__FILE__, 'settings.tpl');}public function hookHeader() {return $this->displaySettings();}} Here you can see I have taken a blank array and in that blank array I am pushing all the values for the variables from getContent function. After pushing them I want to fetch them inside displaySettings function. So that I can use all the variable in the samrty template. But its not working. Even I have done var_dump inside displaySettings function its showing me a blank array. So can someone tell me how to get those values in displaySettings settings so that I can use them inside smarty? Any help and suggestions will be really apprecaible. Thanks 1 Link to comment Share on other sites More sharing options...
rytiz2873 Posted December 30, 2014 Share Posted December 30, 2014 (edited) what you want to do? form in BackOffice or just use some static variables in FrontOffice template? Edited December 30, 2014 by rytiz2873 (see edit history) Link to comment Share on other sites More sharing options...
prestashop_newuser Posted December 30, 2014 Author Share Posted December 30, 2014 what you want to do? form in BackOffice or just use some static variables in FrontOffice template? I want to show the input value of modules from backoffice to the frontOffice template. Link to comment Share on other sites More sharing options...
razaro Posted December 30, 2014 Share Posted December 30, 2014 I think you are missing few things there. For example check module block social https://github.com/PrestaShop/blocksocial/blob/master/blocksocial.php and getContent function. First you can use Configuration class to save your settings to database, then renderForm function must have submit and you need to catch values from that submit in getContent function and save them. Later you can get those values and use in any hook. 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