Jump to content

[solved] BlockCategories smarty variable doesnt work


romain34

Recommended Posts

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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...