Custom Quote Template Beta

dmytro
Participant

Hide Quote comments block if it's empty

 

Hello

 

How it's possible to hide Quote comments block if it's empty (see screenshot)

 

screenshot-71.png

 

 

In code it looks like this:

 

<h2 class="comments-title text-center">Comments</h2>
{% module "comments" label="Comments" path="@hubspot/rich_text" extra_classes="comments-block" html={{ module_defaults.comments }} %}

 

 

5 Replies 5
amin-laanaya
Participant

Hide Quote comments block if it's empty

Wrapped it around the div incorrectly the first time, making me think that "QUOTE.hs_comments" didn't work. The method of wrapping from @arlogilbert should still work. But since that post Hubspot has updated the templates. Use the below code (copy and paste) for ease.

 

{% if QUOTE.hs.comments|length > 0 %}
  <div class="container comments">
    <div class="comments-text_wrapper">
      {% module "comments"
        label="Comments"
        path="@hubspot/rich_text"
        html={{
          "<h2>" ~ template_translations.comments_from.message ~ " " ~ ptoken_sender_full_name ~ "</h2>" ~
          ptoken_comments
        }}
      %}
    </div>
  </div>
{% endif %}

 

 

 

 

 

0 Upvotes
kygoco
Member

Hide Quote comments block if it's empty

Hey Amin,

 

This works great! But any idea, how to also remove the border/layout around the comment block when there are no comments? 

0 Upvotes
amin-laanaya
Participant

Hide Quote comments block if it's empty

If done correctly, it should work.
Could you share your code?

0 Upvotes
arlogilbert
Contributor

Hide Quote comments block if it's empty

Just wrap the module tag with this:

 

{% if QUOTE.hs_comments|length > 0 %}
<h2 class="comments-title text-center">Comments</h2>
{% module "comments" label="Comments" path="@hubspot/rich_text" extra_classes="comments-block" html={{ module_defaults.comments }} %}
{% endif %}

 

dmytro
Participant

Hide Quote comments block if it's empty

Thank you @arlogilbert 

This is what I looking for!

0 Upvotes