开发者

Iterating over collection in mailchimp template via API

Is there any chance to fill in repeatable sections via API? So for example I have list of products and I want to have product section only once in template and then iterate over collection. I have read previous discussion on this topics and googled but I still don't understand whether it is possible via an API.

 <!-- repeatable block -->
 <div mc:repeatable>
   <h2 mc:edit="product_title">Title</h2>
   <p mc:edit="product_description">Body</p>
 </div>
 <!-- /repeatable -->

So can I supply something like this:

 html_product_title[0] = "Product1"
 html_product_description[0] = "Description1"
 html_product_title[1] = "Pr开发者_如何学JAVAoduct2" 
 html_product_description[1] = "Description2"

And have this repeatable section repeated twice? Or maybe I have to name keys in some kind of another manner?

Thanks!


Short answer: No

I just answered this more in depth on another S.O. question

Mailchimp API and Repeatable Sections

Short answer why it doesn't work: The repeatable sections are available with the mailchimp WYSIWYG editor (Custom CKEdit) .. It uses the repeatable tag (mc:repeatable) to duplicate the content.

From the standpoint of the API, the content / sections available are only those on the original template... Even if you edit and/or repeat a section and pull the campaignTemplateContent method it will return the content of the original template.. (Because it is the base template being used)...

The mc:edit, mc:repeatable, and mc:hidable fields all are part of their custom editor...

The mc:edit field is also used to determine the content sections... (This is why the api calls return the FULL html contents of the tagged sections...)

Your best bet is to generate the template on the fly and then upload it using the API... That or if you have a static number of products you are including you could set a template and then just fill in the sections (if you setup the BASE template with the sections, each section will have a custom mc:edit identifier that can be used to populate the sections..)

Each section will be prepended with an identifuer... e.g. 'repeated_content00' 'repeated_content01'... But again, this is in the base template (not campaign edited template)...

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜