6

Is there a way to make the dump() function available in my plugin templates when devMode is disabled?

1 Answer 1

5

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.

2
  • 1
    I'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) 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? Sep 20, 2017 at 19:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.