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

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Post Reply
scooper
Forum Members
Forum Members
Posts: 242
Joined: Fri Dec 09, 2005 12:36 pm
Location: Marlow, UK

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

Post 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.
User avatar
manuel
Power Poster
Power Poster
Posts: 353
Joined: Fri Nov 30, 2007 9:15 am

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

Post 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
Do you like your open source cms? Buy from the CMSMS partners || Donate
User avatar
manuel
Power Poster
Power Poster
Posts: 353
Joined: Fri Nov 30, 2007 9:15 am

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

Post by manuel »

And i just did :)
thx again!

Greetings,
Manuel
Do you like your open source cms? Buy from the CMSMS partners || Donate
Post Reply

Return to “Tips and Tricks”