Jump to content

[solved] How To view module smarty variables


shoulders

Recommended Posts

Hi,

 

I am not an experienced developer but i was hoping there was an easy solution to this.

 

I am developing my own 'homefeatured' module and using the code as a base. My problem is that i need to see what is in the variable $products in homefeatured.tpl so i can use this data. However when i turn on smarty debug and i get the console/java page with all the variables displayed it only shows the variables of the homepage (probably just global) this i am guessing is because the homefeatured.tpl has already been parsed so no smarty variables for this module are therefore present when the console/debug page pops up.

 

Is there a way so i can see the variables from the module, not just the main page.

 

Thanks

Edited by shoulders (see edit history)
Link to comment
Share on other sites

Hello!

 

What you can do is to add {debug} in the tpl file.

 

In the backoffice, make sure to select "open the console with a parameter". In that way, smarty debug is on and with the {debug} in the tpl file, it will show you the SMARTY variable available for that tpl.

 

Hope this will help you.

  • Like 2
Link to comment
Share on other sites

  • 2 weeks later...

Hi, sorry for my English, I worked that either me, you must edit the file prestashop/config/smarty.config.inc.php

line: 42: and where it says $smarty->debugging, put $smarty->debugging = true;

When finished re-set it to false.

 

Un saludo,

Link to comment
Share on other sites

none of the above works. they all turn debugging on and then prestashop/smarty outputs the values on the page at that time not the modules which have bee pre-parsed.

 

The solution is as follows:

 

In the template (.tpl) of the module you are working with, you need to add the following line swapping $var with the variable you want to output to the screen. The variable needs to of been passed to the template with smarty->assign from its corresponding .php file otherwise this will not work.

 

{$var|print_r}

 

If the font is the wrong colour and you can't read it try:

 

<span style="color: white;">{$var|print_r}</span>

 

I used the following webpages for help

I hope this helps someone. It allowed me to diagnose why data was not getting used proprely in my module. Also a cool feature of this is that you can assign any variable in the .php file with smarty, have this passed to the template and then you can show the data on screen. It does not have to be a variable already present in a module.

Edited by shoulders (see edit history)
  • Like 3
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...