开发者

Mailchimp API and Repeatable Sections

开发者 https://www.devze.com 2023-02-10 14:04 出处:网络
Has anyone been able to successfully use the Mailchimp API to populate repeatable areas? Have tried all sorts, but to no avail.

Has anyone been able to successfully use the Mailchimp API to populate repeatable areas?

Have tried all sorts, but to no avail.

In the template, I have:

div mc:repeatable

div mc:edit="repeat_content"

This suggest开发者_如何学编程s that the array should be:

$content['repeat_content'][] = "Content 1";

$content['repeat_content'][] = "Content 2";

However, when calling campaignTemplateContent

It returns

array['repeat_content'] = Content1Content2

And nothing gets replaced in the Email that is sent.

When I remove the mc:repeatable div and just have mc:edit - the content is replaced fine.

Any help would be much appreciated!


Each repeatable content section has its own unique mc:edit identifier...

If you use the templateInfo method and view the contents of the "sections" array, you will see each is appended with an index number (00, 01, etc...)

So in your example, the code would be something like: $content['repeat_content00'] = "Content 1"; $content['repeat_content01'] = "Content 2";

etc...

Also important to note that through the API you cannot add repeatable sectinns - only populate the existing ones (you cant hide them either)....

The mc:edit fields govern the sections of a template.. When you create a campaign it copies the template into the campaign (visable with the camptaignTemplateContent method).

If you create a campaign on MailChimps site, repeat a section, and call the campaignTemplateCOntent method you will notice it does not include the repeated section/content... The campaignTemplateContent is the raw copy of the template.

Now if you call the campaignContent method you will see the html (and/or text) content with repeated sections/modifications...

Think of it like this: You have your templates. When you create a campaign it copies the template into the campaign (campaignTemplateContent)

When you edit the campaign template in mailchimp's editor you can repeate sections.. The modified data is actually stored in the campaignTemplateContent section...

The MailChimp WYSIWYG editor (customized CKEditor) uses the mc:edit, mc:repeatable and mc:hidable tags to edit the campaignContent (I am sure the editor also pulls from the campaignTemplateInfo). But these tags mean nothing to the api.. The API just pulls the mc:edit fields to determine the custom content sections...

Ultimately, if you need an adaptable template for the API, you should create the content on the client side and then pass it to mailchimp.


Just an interesting observation I just found: The MC editor pulls from the original template and stores the edited/ediable values in campaignTemplateContent... (The rendered version is stored in campaignContent...)

The campaignTemplateContent is ordered by the order of the template mc:edit fields..

So when you modify a template the campaignTemplateContent fields will reorder based on the new template...

Also, after creating a campaign - if you edit the template and remove a section the section is still stored in the campaignTemplateContent...

Just interesting because somewhere in that mess is the logic for overcomming the ordering/sorting issue

0

精彩评论

暂无评论...
验证码 换一张
取 消