Is there a way to make the dump() function available in my plugin templates when devMode is disabled?
1 Answer
Add this to your plugin/controller:
if (!craft()->config->get('devMode'))
{
craft()->templates->getTwig()->addExtension(new \Twig_Extension_Debug());
}
Thanks to the all-knowing Brandon Kelly, who posted the solution on Slack.
-
1I'm trying to integrate this code in my custom plugin. Not sure where to put it - the constructor for Controller class doesn't work (neither does the main plugin class constructor). Can you specify a bit more how to make this work? (I'm using Craft 2.5.2754) Commented Dec 13, 2015 at 8:43
-
Same, I don't understand exactly where/how to add this code snippet in? I'm wondering if Craft has an update that makes this irrelevant now? Commented Sep 20, 2017 at 19:29