romain34 Posted April 12, 2013 Share Posted April 12, 2013 Hi all, I begin to developp website with prestashop and i am currently encountering an issue that i can not resolve by myself. I have created and assignated a new smarty variable in the blockcategories.php file and i can't get it in the matching tpl file. In blockcategories.tpl, whatever if i try to access to this variable with {$variable|print_r} or with a foreach loop, i only get a '0' value displayed on page. I am sure that my array variable is not empty as i displayed it in the php file. With the smart debug console, i don't see my variable. Here is a sample of my code which has exactly the same behaviour: Blockcategories.php: $arr = array(1, 2, 3); $this->smarty->assign('test', $arr); Blockcategories.tpl: {foreach from=$test item= resultat} {$resultat} {/foreach} I sincerely hope that someone willbe able to helm me ... Regards, Romain Link to comment Share on other sites More sharing options...
vekia Posted April 12, 2013 Share Posted April 12, 2013 maybe try to use other way to assign new variable: $arr = array(1, 2, 3); global $smarty; $smarty->assign(array('variable'=>$arr)); Link to comment Share on other sites More sharing options...
romain34 Posted April 12, 2013 Author Share Posted April 12, 2013 Ok, thank's Vekia. Now i can see the variable in the smarty console. But, i can't access to its content in the blockCategries.tpl file. Any idea ? Thank's Link to comment Share on other sites More sharing options...
vekia Posted April 12, 2013 Share Posted April 12, 2013 you creating this assign function in correct function displayYOUR_HOOK(){} ? Link to comment Share on other sites More sharing options...
romain34 Posted April 12, 2013 Author Share Posted April 12, 2013 Many thank's .... It works ! I had to switch my code in the function hookHeader() instead of function hookLeftColumn() . But i don't really understand : the block categories is dislayed in the left column on my page, so why to declare this smarty in the header display function? Thank's Link to comment Share on other sites More sharing options...
vekia Posted April 12, 2013 Share Posted April 12, 2013 thanks for information that it works, now i can go ahead and mark this thread as solved for other forum members. to be honest, i dont exactly know why it isnt work well with correct hook ... Maybe some other code isnt working well, i dont know anyway, it works now 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