0

So when you convert a template to an email, the code locks, and only content blocks such as code snippets remain editable. As such my core variables like brand, environment, template_name in a white-labeled project are declared in a code snippet inside of a content area; inside the HTML. The problem is that above in the CSS, I want to run amp script to edit a color and font based on the brand and environment values. However, since the amp script in the CSS executes before those two values are defined; the variables for the CSS are empty. Moving the AMPscript out of the content area and above the HTML tags will lock it from being edited in the template phase.

Edit:

Sample four (4) content area template.

  1. data-type="slot" data-key="template_amp_script"
  2. data-type="slot" data-key="template_header"
  3. data-type="slot" data-key="template_content"
  4. data-type="slot" data-key="template_footer"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0" >
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" >
    <meta name="description" content="A page's description, usually one or two sentences. 155 characters" >
    <title>
      55-60 characters
    </title>
    <style type="text/css">
      ReadMsgBody{
        width: 100%;
      }
      .ExternalClass {
        width: 100%;
      }
      .ExternalClass, .ExternalClass p, .ExternalClass span, .ExternalClass font, .ExternalClass td, .ExternalClass div {
        line-height: 100%;
      }
      body {
        -webkit-text-size-adjust:100%;
        -ms-text-size-adjust:100%;
        margin:0 !important;
      }
      p {
        margin: 1em 0;
      }
      table td {
        border-collapse: collapse;
      }
      img {
        outline:0;
      }
      a img {
        border:none;
      }
      @-ms-viewport{
        width: device-width;
      }
    </style>
    <style type="text/css">
      @media only screen and (max-width: 480px) {
        .container {
          width: 100% !important;
        }
        .footer {
          width:auto !important;
          margin-left:0;
        }
        .mobile-hidden {
          display:none !important;
        }
        .logo {
          display:block !important;
          padding:0 !important;
        }
        img {
          max-width:100% !important;
          height:auto !important;
          max-height:auto !important;
        }
        .template-header img{
          max-width:100% !important;
          height:auto !important;
          max-height:auto !important;
        }
        .template-body img{
          max-width:100% !important;
          height:auto !important;
          max-height:auto !important;
        }
        .template-footer img{
          max-width:100% !important;
          height:auto !important;
          max-height:auto !important;
        }
        .photo img {
          width:100% !important;
          max-width:100% !important;
          height:auto !important;
        }
        .drop {
          display:block !important;
          width: 100% !important;
          float:left;
          clear:both;
        }
        .footerlogo {
          display:block !important;
          width: 100% !important;
          padding-top:15px;
          float:left;
          clear:both;
        }
        .nav4, .nav5, .nav6 {
          display: none !important;
        }
        .tableBlock {
          width:100% !important;
        }
        .responsive-td {
          width:100% !important;
          display:block !important;
          padding:0 !important;
        }
        .fluid, .fluid-centered {
          width: 100% !important;
          max-width: 100% !important;
          height: auto !important;
          margin-left: auto !important;
          margin-right: auto !important;
        }
        .fluid-centered {
          margin-left: auto !important;
          margin-right: auto !important;
        }
        /* MOBILE GLOBAL STYLES - DO NOT CHANGE */
        body {
          padding: 0px !important;
          font-size: 16px !important;
          line-height: 150% !important;
        }
        h1 {
          font-size: 22px !important;
          line-height: normal !important;
        }
        h2 {
          font-size: 20px !important;
          line-height: normal !important;
        }
        h3 {
          font-size: 18px !important;
          line-height: normal !important;
        }
        .buttonstyles {
          font-family:arial,helvetica,sans-serif !important;
          font-size: 16px !important;
          color: #FFFFFF !important;
          padding: 10px !important;
        }
        /* END OF MOBILE GLOBAL STYLES - DO NOT CHANGE */
      }
      @media only screen and (max-width: 640px) {
        .container {
          width:100% !important;
        }
        .mobile-hidden {
          display:none !important;
        }
        .logo {
          display:block !important;
          padding:0 !important;
        }
        .photo img {
          width:100% !important;
          height:auto !important;
        }
        .nav5, .nav6 {
          display: none !important;
        }
        .fluid, .fluid-centered {
          width: 100% !important;
          max-width: 100% !important;
          height: auto !important;
          margin-left: auto !important;
          margin-right: auto !important;
        }
        .fluid-centered {
          margin-left: auto !important;
          margin-right: auto !important;
        }
      }
    </style>
    <!--[if mso]>
      <style type="text/css">
        /* Begin Outlook Font Fix */
        body, table, td {
          font-family: Arial, Helvetica, sans-serif ;
          font-size:16px;
          color:#000000;
          line-height:1;
        }
        /* End Outlook Font Fix */
      </style>
    <![endif]-->
  </head>
  <body bgcolor="#ffffff" text="#000000" style="background-color: #ffffff; color: #000000; padding: 0px; -webkit-text-size-adjust:none; font-size: 16px; font-family:arial,helvetica,sans-serif;">
    <div style="font-size:0; line-height:0;">
      <custom name="opencounter" type="tracking">
      <custom name="usermatch" type="tracking" />
    </div>
    <table width="100%" border="0" cellpadding="0" cellspacing="0" align="center">
      <tr>
        <td align="center" valign="top">
          <custom type="header"/>
        </td>
      </tr>
      <tr>
        <td align="center">
          <table cellspacing="0" cellpadding="0" border="0" width="600" class="container" align="center">
            <tr>
              <td>
                <table class="tb_properties border_style" style="background-color:#FFFFFF;" cellspacing="0" cellpadding="0" bgcolor="#ffffff" width="100%">
                  <tr>
                    <td align="center" valign="top">
                      <table align="left" border="0" cellpadding="0" cellspacing="0" width="100%">
                        <tr>
                          <!-- added padding here -->
                          <td class="content_padding" style="">
                            <!-- end of comment -->
                            <table border="0" cellpadding="0" cellspacing="0" width="100%">
                              <!-- AMP SCRIPT // -->
                              <tr>
                                <td align="center" valign="top">
                                  <!-- NO CLASS NEEDED SINCE WILL NOT DISPLAY -->
                                  <table align="left" border="0" cellpadding="0" cellspacing="0" width="100%">
                                    <tbody>
                                      <tr>
                                        <td align="left" valign="top">
                                          <table cellspacing="0" cellpadding="0" style="width:100%">
                                            <tbody>
                                              <tr>
                                                <td class="responsive-td" valign="top" style="width: 100%;">
                                                  <div data-type="slot" data-key="amp_script" data-max-blocks="1" data-allowed-blocks="codesnippetblock" data-label="Custom AMP Script Content Area">
                                                  </div>
                                                </td>
                                              </tr>
                                            </tbody>
                                          </table>
                                        </td>
                                      </tr>
                                    </tbody>
                                  </table>
                                </td>
                              </tr>
                              <!-- // AMP SCRIPT -->
                              <!-- HEADER // -->
                              <tr>
                                <td align="center" class="template-header" valign="top">
                                  <table align="left" border="0" cellpadding="0" cellspacing="0" width="100%">
                                    <tbody>
                                      <tr>
                                        <td align="left" valign="top">
                                          <table cellspacing="0" cellpadding="0" style="width:100%">
                                            <tbody>
                                              <tr>
                                                <td class="responsive-td" valign="top" style="width: 100%;">
                                                  <div data-type="slot" data-key="header" data-label="Custom Header Content Area">
                                                  </div>
                                                </td>
                                              </tr>
                                            </tbody>
                                          </table>
                                        </td>
                                      </tr>
                                    </tbody>
                                  </table>
                                </td>
                              </tr>
                              <!-- // HEADER -->
                              <!-- BODY // -->
                              <tr>
                                <td align="center" class="template-body" valign="top">
                                  <table align="left" border="0" cellpadding="0" cellspacing="0" width="100%">
                                    <tbody>
                                      <tr>
                                        <td align="left" valign="top">
                                          <table cellspacing="0" cellpadding="0" style="width:100%">
                                            <tbody>
                                              <tr>
                                                <td class="responsive-td" valign="top" style="width: 100%;">
                                                  <div data-type="slot" data-key="body" data-label="Custom Body Content Area">
                                                  </div>
                                                </td>
                                              </tr>
                                            </tbody>
                                          </table>
                                        </td>
                                      </tr>
                                    </tbody>
                                  </table>
                                </td>
                              </tr>
                              <!-- // BODY -->
                              <!-- FOOTER // -->
                              <tr>
                                <td align="center" class="template-footer" valign="top">
                                  <table align="left" border="0" cellpadding="0" cellspacing="0" width="100%">
                                    <tbody>
                                      <tr>
                                        <td align="left" valign="top">
                                          <table cellspacing="0" cellpadding="0" style="width:100%">
                                            <tbody>
                                              <tr>
                                                <td class="responsive-td" valign="top" style="width: 100%;">
                                                  <div data-type="slot" data-key="footer" data-label="Custom Footer Content Area">
                                                  </div>
                                                </td>
                                              </tr>
                                            </tbody>
                                          </table>
                                        </td>
                                      </tr>
                                    </tbody>
                                  </table>
                                </td>
                              </tr>
                              <!-- // FOOTER -->
                            </table>
                          </td>
                        </tr>
                      </table>
                    </td>
                  </tr>
                </table>
              </td>
            </tr>
          </table>
        </td>
      </tr>
      <tr>
        <td valign="top">
          <custom type="footer" />
        </td>
      </tr>
    </table>
  </body>
</html>

Has anyone else run into this issue and come up with an elegant solution? Also does AMPscript execute top down before the html or?

4
  • There's nothing stopping you from adding a content placeholder block anywhere in your template HTML. You can but an editable slot before the beginning <html> tag or in the <head> section if you want. Nov 11, 2020 at 20:10
  • @AdamSpriggs thank you very much for the response; i edited my previous post to include a rough skeleton template with 4 content area's. All inside the <body>. At least from what my understanding is of content areas; i hope i didn't misunderstand. Can you please elaborate on how i can add an editable slot or content area before the <html> or <head> sections if it's not too much trouble. Since i thought that content area's were defined by div elements. Thanks Adam.
    – user80446
    Nov 11, 2020 at 20:18
  • Slots don't have to be in the body. Here's a stripped-down example. AMPscript is compiled and rendered from the top down on the server before the final HTML is sent. It's similar to the way PHP works in a content management system like WordPress. Nov 11, 2020 at 20:20
  • @AdamSpriggs never would have thought to use a div outside the html tag, learn something new every day. Thanks a lot. If you want to submit it as the answer; i'll gladly select it.
    – user80446
    Nov 11, 2020 at 20:56

1 Answer 1

1

Content slots can go anywhere in the template code. They (and what's ultimately contained in them) will be compiled and validated before the send occurs, so feel free to put them wherever is appropriate for your email architecture.

Here's a simple example of what I typically recommend -- INIT, HEAD, BODY, and FOOTER slots.

<div data-type="slot" data-key="init"></div>
<html>
<head>
  <style>
    body, a, input {font-family:sans-serif;}
  </style>
  <div data-type="slot" data-key="head"></div>
</head>
<body>
  <div data-type="slot" data-key="body"></div>
  <div data-type="slot" data-key="footer"></div>
  <custom name="opencounter" type="tracking"></custom>
</body>
</html>

You must log in to answer this question.