0

Does anyone know if there's a way to evaluate whether a custom content block is empty or not using ampscript or SSJS?

For example, if there's a way to detect whether <custom type="content" name="header"> is empty and if it is, then to skip it altogether.

By default, if the custom content block is left empty then it automatically collapses to 1px high. The problem is that when it collapses it creates a 1px space between other content blocks throughout the template.

Well, thanks in advance everyone!

2

You can't do this with templates, but you can within a content area. In a template, those <custom type="content" name="header"> tags are just content area placeholders.

There's nothing stopping you from adding a something like this inside your content area once your emails is created:

%%[

var @header
set @header = ContentAreaByName("My Contents\header")

if not empty(@header) then
  output(concat(@header))
endif

]%%
  • Hi Adam, sorry for the late reply here. I'm having a little bit of trouble visualizing how this would work. So would the code you posted reside at the template level or within the header content area itself? The user workflow here is that the marketer would build an email from the template then would drag and drop the pre-built header content area into the header content bucket. But if the marketer chooses to leave that header bucket empty I'm needing the app to skip that content bucket altogether rather than collapsing it to 1px. Thanks in advance for helping me understand. – Nolan Jan 12 '17 at 23:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.