You are here

function mailchimp_campaign_get_template in Mailchimp 7.3

Same name and namespace in other branches
  1. 8 modules/mailchimp_campaign/mailchimp_campaign.module \mailchimp_campaign_get_template()
  2. 7.5 modules/mailchimp_campaign/mailchimp_campaign.module \mailchimp_campaign_get_template()
  3. 7.4 modules/mailchimp_campaign/mailchimp_campaign.module \mailchimp_campaign_get_template()
  4. 2.x modules/mailchimp_campaign/mailchimp_campaign.module \mailchimp_campaign_get_template()

Return full details for a Mailchimp Template.

Parameters

string $template_id: Optional template ID. Set to return a single MailChimp template.

bool $reset: True if templates should not be loaded from cache.

Return value

mixed An array with all configuration and content for a Mailchimp Template.

3 calls to mailchimp_campaign_get_template()
MailChimpCampaign::buildContent in modules/mailchimp_campaign/includes/mailchimp_campaign.entity.inc
Assemble html representation of the Campaign content.
MailChimpCampaignController::attachLoad in modules/mailchimp_campaign/includes/mailchimp_campaign.controller.inc
Implement in order to attach MailChimp data to campaign entities.
mailchimp_campaign_campaign_form in modules/mailchimp_campaign/includes/mailchimp_campaign.admin.inc
Returns a form for creating a campaign.

File

modules/mailchimp_campaign/mailchimp_campaign.module, line 545
Module file for mailchimp_campaign.

Code

function mailchimp_campaign_get_template($template_id, $reset = FALSE) {
  $all_templates = mailchimp_campaign_list_templates($reset);
  foreach ($all_templates as $type) {
    if (isset($type[$template_id])) {
      $template = $type[$template_id];

      // Get template details from cache or the MailChimp API.
      $cache = $reset ? NULL : cache_get('template_' . $template_id, 'cache_mailchimp');
      if ($cache) {
        $template['info'] = $cache->data;
      }
      else {
        if ($mcapi = mailchimp_get_api_object()) {
          $template['info'] = $mcapi->templates
            ->info($template_id);
          cache_set('template_' . $template_id, $template['info'], 'cache_mailchimp', CACHE_TEMPORARY);
        }
      }
      return $template;
    }
  }
  return NULL;
}