How to hide Hubl module text field if empty

Highlighted
Regular Contributor

What Hubl expression do I need to add to hide the blog subscription title text if the field is empty? I know it can be done using boolean but haven't been able to get it to work, so the H3 tag still shows up if the title is empty. Thanks in advance.

 

Screen Shot 2019-07-30 at 9.19.23 AM.png

Reply
0 Upvotes
3 Replies 3
HubSpot Moderator

Hi @cpburke,

 

I don't think it's possible to remove that HTML from the blog subscription module. If you don't include the title parameter, I believe you get the default value, which is "Subscribe Here!". But you could include some CSS to make sure it doesn't display under certain conditions, or some JS to remove it from the page altogether if you need to. So with CSS you could do something like:

 

{% if not module.title %}
  <style>
    .hs_cos_wrapper_type_blog_subscribe .form-title {
      display: none;
    }
  </style>
{% endif %}

Let me know if you have any questions about this.

 

Leland Scanlan

HubSpot Developer Support
Esteemed Contributor | Diamond Partner

@cpburke 

 

@lscanlan 's solution will work, but you can make it more flexible by using the CSS pseudo :empty selector.

 

.hs_cos_wrapper_type_blog_subscribe .form-title:empty{
  display: none;
}

That way you don't accidentally hide it in other scenarios where it may have content.

Esteemed Contributor | Diamond Partner

Whoops - missed his HUBL markup there - his will work perfectly fine as well. Mine is a pure CSS method whereas his is HUBL + CSS