Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-15306

Adding hook to alter mail templates

    Details

    • Type: New Feature
    • Status: Done/Fixed
    • Priority: Trivial
    • Resolution: Fixed/Completed
    • Affects Version/s: 4.5
    • Fix Version/s: 4.7
    • Component/s: CiviMail
    • Labels:
      None
    • Documentation Required?:
      Developer Doc
    • Funding Source:
      Contributed Code

      Description

      Adding a hook which is called after getting the content of the mail and before tokenizing it.

      Doing this we can alter the content and subject of the mail before it is tokenized and send to the recipients.

      See file attached. I placed the htmlToText() function after the hook implementation because the alter functions should have the original value, I think.

      Why? With this hook we can

      Example implemenation:
      ---------------------------------

      $data = array(
      'apikey' => '<something>',
      'html' => $templates['html'],
      );

      $options = array(
      'method' => 'POST',
      'data' => drupal_http_build_query($data),
      'headers' => array(
      'Content-Type' => 'application/x-www-form-urlencoded',
      ),
      );

      $response = drupal_http_request('https://us2.api.mailchimp.com/2.0/helper/inline-css.json', $options);

      //@todo: check if response is ok

      $result = drupal_json_decode($response->data);

      $templates['html'] = $result['html'];

        Attachments

          Activity

            People

            • Assignee:
              yashodha Yashodha Chaku
              Reporter:
              wdecraene Wim De Craene
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: