Debug a template on a live site using a smarty conditional.
Posted: Thu May 17, 2012 1:50 pm
I just had to fix a templating issue on a live site and wanted to use var_dump to see what smarty info was available.
Obviously I didn't want that information showing up on the live site so I put in a smarty conditional that checked for a query parameter
Then you can just add a query parameter to the URL and you'll see the code in the conditional and your users won't.
So
http://www.millipedia.co.uk/stuff/debugging-smarty.html is what your users see but
http://www.millipedia.co.uk/stuff/debug ... ml?debug=1 is what you see.
Hope that's useful to someone.
s.
Obviously I didn't want that information showing up on the live site so I put in a smarty conditional that checked for a query parameter
Code: Select all
{if $smarty.get.debug eq 1}
//whatever code you want to see here.
{get_template_vars}
{/if}
So
http://www.millipedia.co.uk/stuff/debugging-smarty.html is what your users see but
http://www.millipedia.co.uk/stuff/debug ... ml?debug=1 is what you see.
Hope that's useful to someone.
s.