APIs & Integrations

newrt
Member

Conditional CTA's wrapped in a div

Hi,

I'm looking to make a conditional CTA that essentially has a cta with a div wrapped.

However, I'm looking to make it conditional. So the ability to add it to certain blogs and not on other.

I've spotted this:

Hide widget container if its empty

I'd like to hide a widget container if there isn't any modules inside of it. My code currently looks like this:   Comps {% widget_container "comps_container" %} {% end_widget_container %} What can I wrap...


and written this:

  <div class="footer-cta-block">
    {% if widget_data.cta_footer_text.body.value %}
    has value
      {% widget_block rich_text "cta_footer_text" overrideable=True, label='Footer Cta Area'  %}
        {% widget_attribute "html" %}
        {% end_widget_attribute %}
      {% end_widget_block %}
   {% endif %}
  </div>

but it results in the whole widget not showing in the editor and I'm not sure what approach to take to tackle this one.

Any recommendations would be greatly appreciated.

Many thanks

0 Upvotes
1 Reply 1
Derek_Gervais
HubSpot Alumni
HubSpot Alumni

Conditional CTA's wrapped in a div

Hi @rst88,

Just to make sure that we're on the same page, you're trying to hide the CTA on the page, but keep the widget in the page editor? Can you send me a link to the page you're working on in HubSpot so that I can take a closer look?

0 Upvotes