shoulders Posted January 21, 2013 Share Posted January 21, 2013 (edited) 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 February 10, 2013 by shoulders (see edit history) Link to comment Share on other sites More sharing options...
be_tnt Posted January 21, 2013 Share Posted January 21, 2013 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. 2 Link to comment Share on other sites More sharing options...
shoulders Posted January 23, 2013 Author Share Posted January 23, 2013 thanks for the help, but unfortunately it is doing the same as just turning 'always open console', this shows me the smarty variables on the homepage not those in the module. Maybe i am doing something wrong. i will have a play tomorrow Link to comment Share on other sites More sharing options...
Chirby Posted February 6, 2013 Share Posted February 6, 2013 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 More sharing options...
shoulders Posted February 10, 2013 Author Share Posted February 10, 2013 (edited) 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 var_dump or print_r inside a Smarty template How to Debug Variables in Smarty like in PHP var_dump() How can i print all value of an array 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 February 10, 2013 by shoulders (see edit history) 3 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