htmlmail--simplenews.tpl.php 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <?php
  2. /**
  3. * @file
  4. * Sample template for sending Simplenews messages with HTML Mail.
  5. *
  6. * The following variables are available in this template:
  7. *
  8. * - $message_id: The email message id, or "simplenews_$key"
  9. * - $module: The sending module, which is 'simplenews'.
  10. * - $key: The simplenews action, which may be any of the following:
  11. * - node: Send a newsletter to its subscribers.
  12. * - subscribe: New subscriber confirmation message.
  13. * - test: Send a test newsletter to the test address.
  14. * - unsubscribe: Unsubscribe confirmation message.
  15. * - $headers: An array of email (name => value) pairs.
  16. * - $from: The configured sender address.
  17. * - $to: The recipient subscriber email address.
  18. * - $subject: The message subject line.
  19. * - $body: The formatted message body.
  20. * - $language: The language object for this message.
  21. * - $params: An array containing the following keys:
  22. * - context: An array containing the following keys:
  23. * - account: The recipient subscriber account object, which contains
  24. * the following useful properties:
  25. * - snid: The simplenews subscriber id, or NULL for test messages.
  26. * - name: The subscriber username, or NULL.
  27. * - activated: The date this subscription became active, or NULL.
  28. * - uid: The subscriber user id, or NULL.
  29. * - mail: The subscriber email address; same as $message['to'].
  30. * - language: The subscriber language code.
  31. * - tids: An array of taxonomy term ids.
  32. * - newsletter_subscription: An array of subscription ids.
  33. * - node: The simplenews newsletter node object, which contains the
  34. * following useful properties:
  35. * - changed: The node last-modified date, as a unix timestamp.
  36. * - created: The node creation date, as a unix timestamp.
  37. * - name: The username of the node publisher.
  38. * - nid: The node id.
  39. * - title: The node title.
  40. * - uid: The user ID of the node publisher.
  41. * - newsletter: The simplenews newsletter object, which contains the
  42. * following useful properties:
  43. * - nid: The node ID of the newsletter node.
  44. * - name: The short name of the newsletter.
  45. * - description: The long name or description of the newsletter.
  46. * - $template_path: The relative path to the template directory.
  47. * - $template_url: The absolute url to the template directory.
  48. * - $theme: The name of the selected Email theme.
  49. * - $theme_path: The relative path to the Email theme directory.
  50. * - $theme_url: The absolute url to the Email theme directory.
  51. */
  52. $template_name = basename(__FILE__);
  53. $current_path = realpath(NULL);
  54. $current_len = strlen($current_path);
  55. $template_path = realpath(dirname(__FILE__));
  56. if (!strncmp($template_path, $current_path, $current_len)) {
  57. $template_path = substr($template_path, $current_len + 1);
  58. }
  59. $template_url = url($template_path, array('absolute' => TRUE));
  60. ?>
  61. <?php if ($key == 'node' || $key == 'test'): ?>
  62. <div class="htmlmail-simplenews-link">
  63. <a href="<?php echo url('node/' . $params['simplenews_source']->getNode()->nid, array('absolute' => TRUE)); ?>">
  64. Click here to view this message on the web.
  65. </a>
  66. </div>
  67. <?php endif; ?>
  68. <div class="htmlmail-simplenews-body htmlmail-body">
  69. <?php echo $body; ?>
  70. </div>
  71. <?php if ($debug):
  72. $module_template = 'htmlmail--simplenews.tpl.php';
  73. $message_template = "htmlmail--simplenews--$key.tpl.php";
  74. ?>
  75. <hr />
  76. <div class="htmlmail-simplenews-debug htmlmail-debug">
  77. <dl><dt><p>
  78. To customize your simplenews messages:
  79. </p></dt><dd><ol><li><p><?php if (empty($theme)): ?>
  80. Visit <u>admin/config/system/htmlmail</u>
  81. and select a theme to hold your custom email template files.
  82. </p></li><li><p><?php elseif (empty($theme_path)): ?>
  83. Visit <u>admin/appearance</u>
  84. to enable your selected <u><?php echo drupal_ucfirst($theme); ?></u> theme.
  85. </p></li><li><?php endif;
  86. if ("$template_path/$template_name" == "$theme_path/$message_template"): ?><p>
  87. Edit your<br />
  88. <u><code><?php echo "$template_path/$template_name"; ?></code></u>
  89. <br />file.
  90. </p></li><li><?php
  91. else:
  92. if (!file_exists("$theme_path/htmlmail.tpl.php")): ?><p>
  93. Copy<br />
  94. <u><code><?php echo "$module_path/htmlmail.tpl.php"; ?></code></u>
  95. <br />to<br />
  96. <u><code><?php echo "$theme_path/htmlmail.tpl.php"; ?></code></u>
  97. </p></li><li><?php
  98. endif;
  99. if (!file_exists("$theme_path/$module_template")): ?><p>
  100. For general Simplenews message customization, copy<br />
  101. <u><code><?php echo "$module_path/htmlmail.tpl.php"; ?></code></u>
  102. <br />to<br />
  103. <code><?php echo "$theme_path/$module_template"; ?></code>
  104. </p></li><li><?php
  105. endif;
  106. if (!file_exists("$theme_path/$message_template")): ?><p>
  107. For message-specific customization, copy<br />
  108. <u><code><?php echo "$module_path/htmlmail.tpl.php"; ?></code></u>
  109. <br />to one of the following:
  110. </p><ul><li><dl><dt><p>
  111. <u><code>htmlmail--simplenews--node.tpl.php</code></u>
  112. </p></dt><dd><p>
  113. Regular newsletter template.
  114. </p></dd></dl></li><li><dl><dt><p>
  115. <u><code>htmlmail--simplenews--subscribe.tpl.php</code></u>
  116. </p></dt><dd><p>
  117. New subscriber confirmation message.
  118. </p></dd></dl></li><li><dl><dt><p>
  119. <u><code>htmlmail--simplenews--test.tpl.php</code></u>
  120. </p></dt><dd><p>
  121. Test newsletter.
  122. </p></dd></dl></li><li><dl><dt><p>
  123. <u><code>htmlmail--simplenews--unsubscribe.tpl.php</code></u>
  124. </p></dt><dd><p>
  125. Unsubscribe confirmation message.
  126. </p></dd></dl></li></ul></li><li><?php
  127. endif; ?><p>
  128. Edit the copied file.
  129. </p></li><li><?php
  130. endif; ?><p>
  131. Send a test message to make sure your customizations worked.
  132. </p></li><li><p>
  133. If you think your customizations would be of use to others,
  134. please contribute your file as a feature request in the
  135. <a href="http://drupal.org/node/add/project-issue/htmlmail">issue queue</a>.
  136. </p></li></ol></dd><dt><p>
  137. The simplenews module sets the <u><code>$params</code></u> variable.
  138. For this message,
  139. </p></dt><dd><p><code><pre>
  140. $params = <?php echo check_plain(print_r($params, 1)); ?>
  141. </pre></code></p></dd></dl>
  142. </div>
  143. <?php endif;