Code snippets for symfony 1.x


Hide Web Debug Details and show it on errors

This snippet hides the Web Debug details and show it automatically whenever an error has detect by the Debug System.

This code uses a JavaScript file only for development environment, avoiding unnecessary requests and extra codes in production environment and files.

Obs: Requires jQuery JavaScript Library.

1) Copy the code below and save it as a JavaScript file in "/web/js/debug.js"

    //sfWebDebug Bar Toogler
    var JQsfWebDebug = $('#sfWebDebugDetails');
    (JQsfWebDebug.children('li').hasClass('sfWebDebugError')) ? : JQsfWebDebug.hide();

2) Place the PHP code below in your "/apps/application-name/config/view.yml"

  // your metas, styles, etc... configuration
  javascripts:    [yourScript.js <?php if(sfConfig::get('sf_web_debug')) echo ',debug.js' ?>]

Tip: You can use "debug.js" for all JavaScript debug needs.

by Mario Rezende on 2011-01-15, tagged debug  javascript