xezus Posted May 26, 2013 Share 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) Link to comment Share on other sites More sharing options...
vekia Posted May 26, 2013 Share 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? Link to comment Share on other sites More sharing options...
xezus Posted May 26, 2013 Author Share 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. Link to comment Share on other sites More sharing options...
vekia Posted May 26, 2013 Share 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 Link to comment Share on other sites More sharing options...
xezus Posted May 26, 2013 Author Share 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) Link to comment Share on other sites More sharing options...
vekia Posted May 26, 2013 Share Posted May 26, 2013 $array= array('variable1'=>"value", 'variable2'=>"second value", 'variable3' => "last example"); Link to comment Share on other sites More sharing options...
xezus Posted May 26, 2013 Author Share 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 Link to comment Share on other sites More sharing options...
vekia Posted May 26, 2013 Share 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 Link to comment Share on other sites More sharing options...
xezus Posted May 28, 2013 Author Share Posted May 28, 2013 Thank you a lot vekia it works Link to comment Share on other sites More sharing options...
vekia Posted May 28, 2013 Share 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 Link to comment Share on other sites More sharing options...
Ashish.kumar Posted May 19, 2014 Share Posted May 19, 2014 hello, How we get this value in tpl file?. Could you please provide an example? Link to comment Share on other sites More sharing options...
vekia Posted May 19, 2014 Share 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" 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