HOWTO: Symfony 1.4 – Only load an plugin for a given application

Sometimes you’ll want to include a plugin, such as an admin generator, that will load stylesheets or javascript files that you may not want loaded in all applications.

You could add the following to your template file: (apps/frontend/templates/layout.php)

$sf_response->removeStylesheet('/m14tAdminGeneratorPlugin/css/admin.css');

But that just feels wrong. So instead, lets only load the plugin for the application that we want (config/ProjectConfiguration.class.php):

class ProjectConfiguration extends sfProjectConfiguration {
  public function setup() {
    $this->enablePlugins('sfDoctrinePlugin');
    ...
    if ( "admin" == sfConfig::get('sf_app') ) {
      $this->enablePlugins('m14tAdminGeneratorPlugin');
    }
  }
}

Posted in General

Leave a Reply

Your email address will not be published. Required fields are marked *

*