M2_Mailchimp_Templates

The Membership 2 M2 Mailchimp Templates class.

Defined (1)

The class is defined in the following location(s).

/lib/mailchimp-api/Mailchimp/Templates.php  
  1. class M2_Mailchimp_Templates { 
  2. public function __construct(M2_Mailchimp $master) { 
  3. $this->master = $master; 
  4.  
  5. /** 
  6. * Create a new user template, <strong>NOT</strong> campaign content. These templates can then be applied while creating campaigns. 
  7. * @param string $name 
  8. * @param string $html 
  9. * @param int $folder_id 
  10. * @return associative_array with a single element: 
  11. * - template_id int the new template id, otherwise an error is thrown. 
  12. */ 
  13. public function add($name, $html, $folder_id=null) { 
  14. $_params = array("name" => $name, "html" => $html, "folder_id" => $folder_id); 
  15. return $this->master->call('templates/add', $_params); 
  16.  
  17. /** 
  18. * Delete (deactivate) a user template 
  19. * @param int $template_id 
  20. * @return associative_array with a single entry: 
  21. * - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise. 
  22. */ 
  23. public function del($template_id) { 
  24. $_params = array("template_id" => $template_id); 
  25. return $this->master->call('templates/del', $_params); 
  26.  
  27. /** 
  28. * Pull details for a specific template to help support editing 
  29. * @param int $template_id 
  30. * @param string $type 
  31. * @return associative_array info to be used when editing 
  32. * - default_content associative_array the default content broken down into the named editable sections for the template - dependant upon template, so not documented 
  33. * - sections associative_array the valid editable section names - dependant upon template, so not documented 
  34. * - source string the full source of the template as if you exported it via our template editor 
  35. * - preview string similar to the source, but the rendered version of the source from our popup preview 
  36. */ 
  37. public function info($template_id, $type='user') { 
  38. $_params = array("template_id" => $template_id, "type" => $type); 
  39. return $this->master->call('templates/info', $_params); 
  40.  
  41. /** 
  42. * Retrieve various templates available in the system, allowing some thing similar to our template gallery to be created. 
  43. * @param associative_array $types 
  44. * - user boolean Custom templates for this user account. Defaults to true. 
  45. * - gallery boolean Templates from our Gallery. Note that some templates that require extra configuration are withheld. (eg, the Etsy template). Defaults to false. 
  46. * - base boolean Our "start from scratch" extremely basic templates. Defaults to false. As of the 9.0 update, "base" templates are no longer available via the API because they are now all saved Drag & Drop templates. 
  47. * @param associative_array $filters 
  48. * - category string optional for Gallery templates only, limit to a specific template category 
  49. * - folder_id string user templates, limit to this folder_id 
  50. * - include_inactive boolean user templates are not deleted, only set inactive. defaults to false. 
  51. * - inactive_only boolean only include inactive user templates. defaults to false. 
  52. * - include_drag_and_drop boolean Include templates created and saved using the new Drag & Drop editor. <strong>Note:</strong> You will not be able to edit or create new drag & drop templates via this API. This is useful only for creating a new campaign based on a drag & drop template. 
  53. * @return associative_array for each type 
  54. * - user array matching user templates, if requested. 
  55. * - id int Id of the template 
  56. * - name string Name of the template 
  57. * - layout string General description of the layout of the template 
  58. * - category string The category for the template, if there is one. 
  59. * - preview_image string If we've generated it, the url of the preview image for the template. We do out best to keep these up to date, but Preview image urls are not guaranteed to be available 
  60. * - date_created string The date/time the template was created 
  61. * - active boolean whether or not the template is active and available for use. 
  62. * - edit_source boolean Whether or not you are able to edit the source of a template. 
  63. * - folder_id boolean if it's in one, the folder id 
  64. * - gallery array matching gallery templates, if requested. 
  65. * - id int Id of the template 
  66. * - name string Name of the template 
  67. * - layout string General description of the layout of the template 
  68. * - category string The category for the template, if there is one. 
  69. * - preview_image string If we've generated it, the url of the preview image for the template. We do out best to keep these up to date, but Preview image urls are not guaranteed to be available 
  70. * - date_created string The date/time the template was created 
  71. * - active boolean whether or not the template is active and available for use. 
  72. * - edit_source boolean Whether or not you are able to edit the source of a template. 
  73. * - base array matching base templates, if requested. (Will always be empty as of 9.0) 
  74. */ 
  75. public function getList($types=array(), $filters=array()) { 
  76. $_params = array("types" => $types, "filters" => $filters); 
  77. return $this->master->call('templates/list', $_params); 
  78.  
  79. /** 
  80. * Undelete (reactivate) a user template 
  81. * @param int $template_id 
  82. * @return associative_array with a single entry: 
  83. * - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise. 
  84. */ 
  85. public function undel($template_id) { 
  86. $_params = array("template_id" => $template_id); 
  87. return $this->master->call('templates/undel', $_params); 
  88.  
  89. /** 
  90. * Replace the content of a user template, <strong>NOT</strong> campaign content. 
  91. * @param int $template_id 
  92. * @param associative_array $values 
  93. * - name string the name for the template - names must be unique and a max of 50 bytes 
  94. * - html string a string specifying the entire template to be created. This is <strong>NOT</strong> campaign content. They are intended to utilize our <a href="http://www.mailchimp.com/resources/email-template-language/" target="_blank">template language</a>. 
  95. * - folder_id int the folder to put this template in - 0 or a blank values will remove it from a folder. 
  96. * @return associative_array with a single entry: 
  97. * - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise. 
  98. */ 
  99. public function update($template_id, $values) { 
  100. $_params = array("template_id" => $template_id, "values" => $values); 
  101. return $this->master->call('templates/update', $_params); 
  102.