function mailchimp_campaign_get_templates in Mailchimp 7.2
Return all available user templates.
Return value
array().
4 calls to mailchimp_campaign_get_templates()
- MailChimpCampaign::buildContent in modules/
mailchimp_campaign/ mailchimp_campaign.entity.inc - Builds a structured array representing the entity's content.
- MailChimpCampaignController::attachLoad in modules/
mailchimp_campaign/ mailchimp_campaign.entity.inc - Implement in order to attach MC data to campaign entities.
- mailchimp_campaign_campaign_form in modules/
mailchimp_campaign/ mailchimp_campaign.admin.inc - Returns a form for creating a campaign.
- mailchimp_campaign_overview_page in modules/
mailchimp_campaign/ mailchimp_campaign.module - Page callback for showing a list of MC Campaign entities.
File
- modules/
mailchimp_campaign/ mailchimp_campaign.module, line 307
Code
function mailchimp_campaign_get_templates($template_id = NULL, $reset = FALSE) {
$cache = $reset ? NULL : cache_get('mailchimp_templates');
$templates = array();
// return cached lists
if ($cache) {
$templates = $cache->data;
}
else {
if ($mcapi = mailchimp_get_api_object()) {
$response = $mcapi
->templates(array(
'user' => TRUE,
));
foreach ($response['user'] as $template) {
$tid = $template['id'];
$info = $mcapi
->templateInfo($tid);
// exclude templates with repeating content. This is a current
// limitation of the MC API as repeating sections cannot be updated
// through the API
if (!strpos($info['source'], 'mc:repeatable')) {
$template['info'] = $info;
$templates[$tid] = $template;
}
}
}
cache_set('mailchimp_templates', $templates, 'cache', CACHE_TEMPORARY);
}
if (isset($template_id)) {
return isset($templates[$template_id]) ? $templates[$template_id] : NULL;
}
else {
return $templates;
}
}