Custom Templates and the API

1,604 views
Skip to first unread message

Murray Summers

unread,
Sep 16, 2009, 1:22:21 PM9/16/09
to MailChimp API Discuss
Here is the text of a message I posted yesterday on the Jungle. Sorry for
the duplication.

I'm wanting to use the API to add some HTML content to a custom template.
The API docs show examples of this (I think) -

#
$content = array('html_main'=>'some pretty html content',
#
'html_sidecolumn' => 'this goes in a side column',
#
'html_header' => 'this gets placed in the header',
#
'html_footer' => 'the footer with an *|UNSUB|* message',
#
'text' => 'text content text content *|UNSUB|*'
#
);

So my question is: what are those hooks? Are they EDITABLE regions defined
in the custom template? For example, would this markup specify where the
html_main stuff mentioned in the example above go?

mc:edit="html_main"

Or is it determined by an ID value, e.g.,

<div id="html_main"....? Or what?

Thanks!

Murray

--
Murray R. Summers
Great Web Sights
610-469-9715
msum...@great-web-sights.com
http://www.great-web-sights.com

jesse

unread,
Sep 17, 2009, 11:27:53 AM9/17/09
to MailChimp API Discuss
Murray -
Sorry for the delay in getting back to you - I had barely played with
the template language and definitely had not considered folks trying
to use them with the API, so I had a little catching up to do.

Luckily, it looks custom templates play very nice with the API.
Basically, you can update/set the content sections based on whatever
is in the value mc:edit="XXX" attribute. If there is no value, then we
will name them a generic "content_X" where X increments from 1 to N
from top to bottom in the template. However, if you set something like
mc:edit="header" in the template, then we'll recognize that name for
the section.

Once you have the section names down, they work the same as the
previously defined templates. eg, section "main" is passed in to
campaignCreate or campaignUpdate using "html_main".

One last note - if you run the campaignTemplates method, we return the
sections and the name we expect for them, which will help you verify
that you are using the correct names.

Let me know if I missed something or you have other questions.


jesse

On Sep 16, 1:22 pm, Murray Summers <msumm...@great-web-sights.com>
wrote:
> msumm...@great-web-sights.comhttp://www.great-web-sights.com

Murray Summers

unread,
Sep 17, 2009, 12:13:02 PM9/17/09
to mailchimp-...@googlegroups.com
Jesse:

Thanks for this information!

I tried just what you suggested with a custom template, but the
campaignTemplates method only returned the stock names (header, main,
footer), not the custom editable region names. I will check to make sure
that I didn't do something wrong and let you know, but I have to ask - did
you verify that this actually happens? Or am I misunderstanding how this
should work?

By the way, combining the custom templates with the API is INCREDIBLY
powerful, in that it means you can build a complete email newsletter app for
the client to use without them ever touching mailchimp.com....

Murray
msum...@great-web-sights.com
http://www.great-web-sights.com





jesse

unread,
Sep 17, 2009, 12:22:40 PM9/17/09
to MailChimp API Discuss
Murray -
Yup, I did test it. Just to be sure we're talking about the same
things, I setup my custom template by going to the Dashboard, then My
Templates, the Code Custom templates. Once there I used one of our
example templates from here:
http://www.mailchimp.com/resources/email-template-language

Note that old templates displayed there or anything created from the
"new templates" tag will still have the standard header/main/footer
section names. Since you can also define your section names, you can
also obviously use them in your own custom templates.

One final note in case you didn't see the other thread, you'll
probably have the "how do I retrieve just sections" question soon -
http://groups.google.com/group/mailchimp-api-discuss/browse_thread/thread/71b0c2dd10fb63eb/94cc189a5efbc457#94cc189a5efbc457


jesse

On Sep 17, 12:13 pm, Murray Summers <msumm...@great-web-sights.com>
> msumm...@great-web-sights.comhttp://www.great-web-sights.com

Murray Summers

unread,
Sep 20, 2009, 7:59:26 AM9/20/09
to mailchimp-...@googlegroups.com
I want to close out this thread with a note that Jesse was able to get me
going just fine! Here are the salient points that enabled this:

1. If you are using MCAPI (I was) version 1.1, update to the MCAPI version
1.2. It is this version that recognizes all of the template
commands/operations.

2. Name your editable regions as shown in the documentation, e.g.,
<span mc:edit="volume">Volume 12, Number 2

3. When you refer to these editable regions in your scripting, prefix them
with "html_" (if you are referring to an HTML email) or "text_" (if you are
referring to a text email), e.g.,
$content=array('html_volume'=> 'Volume 12, Number 3',...

It works like a charm!

Thanks, Jesse.

Murray



On 9/17/09 12:22 PM, "jesse" <je...@mailchimp.com> wrote:

>
> Murray -
msum...@great-web-sights.com
http://www.great-web-sights.com





Reply all
Reply to author
Forward
0 new messages