Page 1 of 1

Debug a template on a live site using a smarty conditional.

Posted: Thu May 17, 2012 1:50 pm
by scooper
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

Code: Select all

{if $smarty.get.debug eq 1}

//whatever code you want to see here. 
{get_template_vars}

{/if}
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.

Re: Debug a template on a live site using a smarty condition

Posted: Thu May 17, 2012 4:03 pm
by manuel
Dear Scooper,

Thanks for sharing!
A quick and elegant solution, i will be using it on my live sites for sure! :)

Greetings,
Manuel

Re: Debug a template on a live site using a smarty condition

Posted: Tue Jul 31, 2012 8:50 pm
by manuel
And i just did :)
thx again!

Greetings,
Manuel