bobs@sectorlink Posted October 28, 2015 Report Share Posted October 28, 2015 So I was able to create a email template, but I am not sure how you set the name and description for this temploate. Also, how do I remove the Email/Group, so I can rename it? ---------------------------------------------------------------------------------------------------------------------------------------------------------- /plugins/my_plugin/controllers/admin_main.php <?php class AdminMain extends MyPluginController { public function index() { $this->uses(array("Emails", "EmailGroups")); $group = array( 'action' => "MyPlugin.custom_action", 'type' => "staff", 'plugin_dir' => "my_plugin", 'tags' => "first_name,last_name" ); // Add the custom group $group_id = $this->EmailGroups->add($group); $email = array( 'email_group_id' => $group_id, 'company_id' => $this->company_id, 'lang' => "en_us", 'from' => "no-reply@mydomain.com", 'from_name' => "My Company", 'subject' => "Subject of the email", 'text' => "Hi {first_name}, This is the text version of your email", 'html' => "<p>Hi {first_name},</p> <p>This is the HTML version of your email</p>" ); // Add an email to the group $this->Emails->add($email); } } ?> Quote Link to comment Share on other sites More sharing options...
Tyson Posted October 28, 2015 Report Share Posted October 28, 2015 The example you quoted from the docs only shows a simple example of how to create an email template. You may want to handle this in your plugin's install and uninstall methods so you can create the group and template when your plugin is installed rather than when accessing a controller, as the example illustrates. You can take a look at the Support Manager plugin source for working examples. Set a name and description for the email template by defining a language file, admin_company_emails, containing them, in the following format: File: /plugins/myplugin/language/en_us/admin_company_emails.php Contents: <?php $lang['AdminCompanyEmails.templates.action_name'] = "Email Template Name"; $lang['AdminCompanyEmails.templates.action_desc'] = "Email Template Description"; The "action" in the language term AdminCompanyEmails.templates.action_name should be the action of the email template group you created. For example, your group action is called MyPlugin.custom_action, so the language term would be $lang['AdminCompanyEmails.templates.MyPlugin.custom_action_name'] = "Email Template Name"; Paul 1 Quote Link to comment Share on other sites More sharing options...
bobs@sectorlink Posted October 28, 2015 Author Report Share Posted October 28, 2015 That worked, you rock. Thanks, Tyson Paul 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.