sfEmailTemplate plugin
The sfEmailTemplatePlugin is a symfony plugin that provides email templates management functionality. It includes admin area where user is able to create and manage email subject/body (both html and text versions) and them system-wide constant values are generated for each email template and its elements, e.g. MYTEMPLATE_SUBJECT and MYTEMPLATE_BODY. This way emails can be easily added to mass mailer layers like swift mailer or so. The other cool feature of this plugin is an ability to create and manage tags for email templates. So that user may define template with using of %NAME%, %DATE%, etc tags and they will be replaced with real values on the sending stage.
Installation
- Install the plugin
symfony plugin-install http://plugins.symfony-project.com/sfEmailTemplatePlugin
- Enable module in your settings.yml (optional) in order to have an ability to manage email templates via web interface
- sfsfEmailTemplateAdmin
all:
.settings:
enabled_modules: [default, sfEmailTemplateAdmin ]
- Load default fixtures (optional - it creates a version record)
symfony propel-build-all
symfony propel-load-data backend
- Clear you cache
symfony cc
Manage constants
- Access the email templates management module with the default route:
http://www.example.com/backend.php/sfEmailTemplateAdmin
Use email constants in your application
To use constants from sf_email_template table in a symfony project:
- Put the following line into your main controller symfony file (i.e. index.php, frontend_dev.php, backend.php, etc)
include_once (sfConfigCache::getInstance()->checkConfig('config/db_emailtemplates.yml'));
- You're done. Now you may use settings values in your code, e.g. $mail->setBody(REGISTRATION_BODY) where REGISTRATION is defined in table sf_email_template.
TODO
* Right now when user changes settings values from backend cached file config_db_emailtemplates.yml.php is deleting in frontend and backend environments:
$cache_file = sfConfig::get('sf_root_dir').'/cache/frontend/prod/config/config_db_emailtemplates.yml.php'; sfToolkit::clearGlob($cache_file);
but if you use another environment names you have to go in code actions.class.php and fix it manually.
* There is defined sf_tag_template table where email template tags must be stored but this functionality is not implemented so far
Attachments
- sfEmailTemplatePlugin-0.0.1.tgz (9.3 kB) - added by Voznyak.Nazar on 11/10/07 12:54:36.