Responsive HTML email and Drupal

4 downloads 725 Views 1MB Size Report
Genera8ng HTML emails with Drupal. Linking to content ... Staff spends ~4 hrs/ week manually ... Drupal 7: func8on yourthemename_preprocess_page(&$vars) {.
Responsive  HTML  email   and  Drupal Email Templating with Drupal

Jason Samuels Manager of IT NCFR

Drew Gorton Founder Gorton Studios

Drew Gorton Founder gortonstudios.com

Genera6ng  HTML  emails  with  Drupal Why?  

Linking  to  content  already  on  the  site   Staff  spends  ~4  hrs/week  manually   preparing  HTML  email  

Genera6ng  HTML  emails  with  Drupal Demo  

Create  a  NewsleEer   Add  /  Choose  Content   Save  

Genera6ng  HTML  emails  with  Drupal Normal theming with some problems  

Email  Clients   Absolute  Paths  (Links  and  Images)   Drupal’s  Smarts  

Genera6ng  HTML  emails  with  Drupal Process  

Create  a  Content  Type   Theme  it   Create  and  Send  (repeat)  

Genera6ng  HTML  emails  with  Drupal Problems  

Email  Clients   Absolute  Paths  (Links  and  Images)   Drupal’s  Smarts  

Problem:  Email  Clients  

Problem:  Email  Clients  

Problem:  Absolute  Paths  for  Links   and  Images   #FAIL  

  Read  More  

OK     Read  More  

URL  Func6on   hEp://api.drupal.org/api/drupal/includes!common.inc/func6on/url   D6/D7:  url($path,  array('absolute'  =>  TRUE));  

Problem:  Drupal’s  Smarts   •  What  modules  are  installed?   •  What  permissions  does  this  user  have?   –  Am  I  logged  in?   –  Can  I  edit  this  page?   –  What  ac6ons  can  this  user  take?  

•  Solu6on:  Stooopid  Theming  

Genera6ng  emails  with  Drupal Process  

Create  a  Content  Type   Theme  it   Send  it  

Create  a  Content  Type  

Iden6fy  and  configure  your  fields  

Theme  it Stoopid  

Copy  the  HTML  from  the  email   template   Drop  in  your  content  variables   Leave  out  the  tabs,  smarts,  etc.  

Theme  it Files and Code   Add  a  template  sugges6on  file  for  per-­‐content-­‐type  pages:   Drupal  6:            func6on  yourthemename_preprocess_page(&$vars)  {          if  (isset($vars['node']))  {              //  If  node  type  is  "newsleEer",  it  will  pickup  "page-­‐newsleEer.tpl.php".              $vars['template_files'][]  =  'page-­‐'.  str_replace('_',  '-­‐',  $vars['node']-­‐>type);          }      }      Drupal  7:          func6on  yourthemename_preprocess_page(&$vars)  {          if  (isset($vars['node']-­‐>type))  {              //  If  node  type  is  "newsleEer",  it  will  pickup  "page-­‐newsleEer.tpl.php".              $vars['theme_hook_sugges6ons'][]  =  'page-­‐'  .  str_replace('_',  '-­‐',  $vars['node']-­‐>type);          }      }  

Theme  it page-newsletter.tpl.php  

Copy  your  email  template  and  add   the  page-­‐level  content  /  variables   – Title,  logo…  

Theme  it node-newsletter.tpl.php  

Theme  &  Preprocess  your  nodes   Render  out  the  content  using   acceptable  low-­‐grade  newsleEer   HTML  

Send  it Manual Send = Better   Copy-­‐Paste  that  HTML  to  your  tool  (MailChimp,  Listserv,  etc).     TEST!      Drupal  can  send  your  email  newsleEer  directly  -­‐-­‐  but  YIKES   (I  click  submit  and  20,000+  people  get  an  email?!?!)  

Responsive  HTML  email   and  Drupal Questions?

Jason Samuels Manager of IT NCFR

Drew Gorton Founder Gorton Studios