Mailchimp API and Repeatable Sections

a 夏天 提交于 2019-12-04 07:42:39
CarpeNoctumDC

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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!