xezus 6 Posted May 26, 2013 (edited) Hi, I am having a problem with adding values to my new array which I created in my new module. public function install() { return (parent::install() ...... && Configuration::updateValue('my_array', array()) ..... } Please could somebody tell me how could I add a new value to this array? I would be glad for any answer. Edited May 28, 2013 by vekia (see edit history) Share this post Link to post Share on other sites
vekia 8,950 Posted May 26, 2013 hello in the topic title you're talking about smarty, but as i can see in the code that you pasted, you don't use smarty. So my questions is, what you exactly expect? Share this post Link to post Share on other sites
xezus 6 Posted May 26, 2013 I am sorry I am new in prestashop but I would like to create a array in my modul and dynamically add values into it and then use this array in my theme like normal smarty array (like $css_files for example) And from what I understand until know is that I have to create php array like this and then use this public function hookDisplayHeader($params) { $this->context->smarty->assign( array( ...'name' => my created array..... ) ); } to enable me to use the array in my theme. Share this post Link to post Share on other sites
vekia 8,950 Posted May 26, 2013 that's right, so you've got solution with code that you pasted you can use {$name} variable in your theme - this is the array that you created Share this post Link to post Share on other sites
xezus 6 Posted May 26, 2013 (edited) Yes, but I don't know how to add values into this array Edited May 26, 2013 by xezus (see edit history) Share this post Link to post Share on other sites
vekia 8,950 Posted May 26, 2013 $array= array('variable1'=>"value", 'variable2'=>"second value", 'variable3' => "last example"); Share this post Link to post Share on other sites
xezus 6 Posted May 26, 2013 sorry for so many questions but how could I do this after that. When the array is already created and I just need to add another value into the array. 1 Share this post Link to post Share on other sites
vekia 8,950 Posted May 26, 2013 $array=array('variable1'=>"value", 'variable2'=>"value2"); $array['new_value']="my new variable"; effect: Array ( [variable1] => value [variable2] => value2 [new_value] => my new variable ) 1 Share this post Link to post Share on other sites
xezus 6 Posted May 28, 2013 Thank you a lot vekia it works Share this post Link to post Share on other sites
vekia 8,950 Posted May 28, 2013 you're welcome it works so i can mark this thread as solved if you've got any questions related to arrays and smarty variables - feel free to continue discussion here regards Share this post Link to post Share on other sites
Ashish.kumar 0 Posted May 19, 2014 hello, How we get this value in tpl file?. Could you please provide an example? Share this post Link to post Share on other sites
vekia 8,950 Posted May 19, 2014 if in php you use code like: $smarty->assign(array('variable1'=>'value1', 'variable2' => 'value2')); to access these variables in tpl file use: {$variable1} - it will display "value1" {$variable2} - it will display "value2" Share this post Link to post Share on other sites