Support

Home Forums Event Espresso Premium CSS for Custom Email Messages

CSS for Custom Email Messages

Posted: September 19, 2017 at 8:06 am

Viewing 3 reply threads


sogtalks@gmail.com

September 19, 2017 at 8:06 am

I am struggling with generating and styling custom emails.
I want to have a header and footer that will be common to ALL the default emails as well as updating the css to reflect our design.

I have followed https://github.com/eventespresso/event-espresso-core/blob/master/docs/E–Messages-System/registering-message-template-variations.md and the other supporting documents.

I have created a class and plugin as per instructions. I have created a plugin folder “eea-new-templates” uploaded “ee-new-messages-template-pack-sogt.php” to that folder. Added a folder “variations”. See below:

define( 'EE_NEW_TP_TEST_VERSION', '1.0' );
define( 'EE_NEW_TP_TEST_FILE', __FILE__ );
define( 'EE_NEW_TP_PATH', plugin_dir_path( __FILE__ ) . '/' );
define( 'EE_NEW_TP_URL', plugin_dir_url( __FILE__ ) . '/' );
function ee_new_messages_template_pack_sogt_load_textdomain() {
	load_plugin_textdomain( 'ee-new-messages-template-pack-sogt', FALSE, dirname( plugin_basename( __FILE__ ) ) . '/lang/' );
}
add_action('plugins_loaded', 'ee_new_messages_template_pack_sogt_load_textdomain');
function ee_new_template_pack_sogt_register_new_variation() {
	if ( ! class_exists( 'EE_Messages_Template_Pack_New_Template_Pack_Sogt' ) ) {
		return;
	}
	$setup = array(
		'path' => rtrim(EE_NEW_TP_PATH, '/'),
		'classname' => 'EE_Messages_Template_Pack_New_Template_Pack_Sogt',
		);
	EE_Register_Messages_Template_Pack::register( 'ee_new_template_pack_sogt', $setup );
}
add_action( 'EE_Brewing_Regular___messages_caf',  'ee_new_template_pack_sogt_register_new_variation' );

have created a class “EE_Messages_Template_Pack_New_Template_Pack_Sogt”

public function _set_props() {
		$this->label = __('SOGT Pack', 'event_espresso');
		$this->dbref = 'new_template_pack_sogt';
		$this->description = __('This is a new template pack for SOGTalks.', 'event_espresso');
		$this->_base_url = EE_NEW_TP_URL . 'eea-new-templates/';
		$this->_base_path = EE_NEW_TP_PATH . 'eea-new-templates/';

added arrays for all default templates.

1) where do I put the class file?
2) where do i get/put the css files(s)
3) do i need to copy/create custom templates for every single message type (emails only)

Thank you, love the plugin!
WordPress 4.8.1
Event Espresso 4.9.46.p


Josh

  • Support Staff

September 19, 2017 at 8:29 am

Hi there,

You put all of your custom code within its own plugin. We have some documentation that outlines how to start with a blank plugin here:

https://eventespresso.com/wiki/create-site-specific-plugin-wordpress-site/

If all you’re doing is adding a header and a footer, then you may not need to copy any templates. If you take a look in email_main_wrapper.template.php you’ll find action hooks before and after the main body of the email, which can be used to add a header and a footer. Any callback functions that hook into those action hooks can also be added to your plugin.

One thing to keep in mind is after you’ve activated your plugin you may need to switch to the variation and reset the message template in the message editor for the new templates to take affect.


sogtalks@gmail.com

September 19, 2017 at 9:52 am

Thanks for the quick response.

I’ve built a few plugins for EE already, I am just confused about the instructions on https://github.com/eventespresso/event-espresso-core/blob/master/docs/E–Messages-System/registering-message-template-packs.md.

So in that explanation Step One: Setup the Template Pack class code, the variations code and Step Three: Register your new template pack code should all be in the plugin?.

What about the css?

Thanks for your help.


Josh

  • Support Staff

September 19, 2017 at 9:59 am

Yes all of your custom code should be put into the plugin.

Viewing 3 reply threads

The support post ‘CSS for Custom Email Messages’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso