If dynamic content is empty can I stop element from rendering?

The div in the image below with class page-header__lead is being populated by an ACF field {acf_page_banner_text} using dynamic data.

If this field is empty can I have this element not render at all?

Right now it is rendering a blank div with extra space.

Or should I just use a code block and use an IF statement as I normally would in theme like this:

<?PHP
    if(get_field('page_banner_text')) {
        echo "<p class='page-header__lead'>" . get_field('page_banner_text') . "</p>";
    }
?>

Hey Jon,

that’s what element conditions are for:

Best,

André

1 Like

Thank you! This is my second Bricks website and I forgot that each element has conditions.

I had resorted to using a code block to check the ACF field but your solutions is 1000% better.

<?php

if(get_field('page_banner_text'))
{
    echo "<p class='page-header__lead'>" . get_field('page_banner_text') . "</p>";
}
?>