Mailchimp mc:hideable hides the wrong section within repeatable block

3.5k views Asked by At

I've built a custom mailchimp template and added repeatable and hideable sections so my client can edit it more easily. I have read all the documentation, my code validates, and the email itself functions great, except for one problem. Here's the gist of my layout - and ideally how I would like it to work (all extraneous code removed - but I can supply it separately if needed).

<table mc:repeatable>
  <tr>
    <td><img src="" alt="article image"></td>
  </tr>

  <tr>
    <td>
       <h2 mc:edit="article_title" mc:hideable>Optional Title</h2>
       <div mc:edit="article_body" mc:hideable>Optional content</div>
    </td>
  </tr>

  <tr>
    <td>
        <div mc:edit="article_button" mc:hideable><a href="" class="button">Optional Styled Button</a></div>
    </td>
  </tr>
</table>

When I go into the campaign editor, I can hide sections successfully. UNTIL I duplicate the block. Once I have 2 blocks, and I hide the 1st block's h2, it hides the following div. If I hide the div, it hides the button. Note: within campaign editor it appears to hide things properly. Only when I preview the email can I see that it's hiding the wrong sections.

I have tried every variation I can think of:

  1. Nesting tables for each piece of hideable content
  2. Separating the edit and hideaable tags to parent/child elements
  3. Renaming all the mc:edit attributes
  4. Moving mc:repeatable to the tr or nested tables instead
  5. Removing mc:hideable completely, except for the button (So they would delete copy rather than hiding the whole section.)

Item 5 above resulted in a completely different problem. When I duplicated the block and hid the button on the replicated block, it hid the button in the FIRST section. It's like the names are getting crossed somehow.

There's gotta be something I'm missing. Mailchimp's documentation seems really straightforward and I haven't been able to find anything about this specific issue.

Thanks in advance!

1

There are 1 answers

2
Felix Eve On BEST ANSWER

As a workaround instead of creating mc:hideable elements inside the mc:repeatable block I've created multiple variants using mc:variant, and each variant has different items inside it.

So in your example your varients would be:

  • Block
  • Block with title
  • Block with content
  • Block with button
  • Block with title and content
  • Block with title and button
  • Block with title and content and button
  • Block with content and button

This is not quite as neat as a solution but it does work.

See here for mc:variant syntax.