x

Hard found gains in Symfony

September 2nd, 2008
post #126   Web Computing »

My first production Symfony application is a newletter manager and sender. This gave me a few headaches that I couldn’t easily find solutions for in the Docs. In the end trial, error and other sources came up with some gems that kept things moving.

Assigning complete module output to a variable

sfContext::getInstance()->getController()->ยป
getPresentationFor(’module’,'action’);

This is pretty useful, dropped into your Action this retrieves the fully rendered (layout, template, content) output of another Action/Module. Many of the email examples recommend putting the content you wish to send out into a partial or component and show how to grab it for variable assignment, but this will take a whole page you might want to email ‘as is’. I use it retrieve a current newsletter page as it is would be rendered for the web so I can drop it into an email.

Flexible but full Absolute URLs to assets

mymodule:
  stylesheets:    [main , 'https://mysiteDotCoDotUK/path/to/this.css']
  javascripts:    ['https://mysiteDotCoDotUK/path/to/that.js']

The books don’t seem to mention it, but you can use absolute URLs in your view.yml for embedding stylesheets and javascripts. So you can set granular stylesheet and script settings down to the module while still producing absolute links to them. When your assets also use the absolute=>true boolean options in Link and Asset Helpers, then you have dynamically generated fully standalone output. I’ll be using this to make sure email newsletters find their supporting content.

With this, I can provide the editor interface, management and preview options, a live copy of the current newsletter and archive of old ones on the web, and share the very same content in mails to subscribers.


Stumble it! | save to del.icio.us save this entry to del.icio.us

Leave a Reply