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)


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() {
    if ( "admin" == sfConfig::get('sf_app') ) {

Posted in General

Sending emails from a task in Symfony 1.4

Sending emails from a task seems like it would be a pretty common, and therefore straightforward task (automated from a cron job for example), but in Symfony its not exactly trivial.

The main reason is that you don’t have a context set from the task, and if you create one it doesn’t know the domain to use when you generate absolute url’s. If you follow Symfony’s Documentation and add a host to the context of your routes, sfDoctrineRoute’s stopped working for me.

While I don’t like tying routing to my models, the solution at worked for me. Just watch out for the following erroneous line:
'is_secure' => sfConfig::get('app_host', false),

Posted in Tech Tagged with: , ,

Protected: Merry Christmas!

This content is password protected. To view it please enter your password below:

Posted in General