CMS Development

pixelilly
Participant | Platinum Partner
Participant | Platinum Partner

Hide a table row/cell if it is empty

SOLVE

Hello devs! I am trying to figure out a way to hide a hubdb table row if it's empty. My client wants to be able to remove the dates from a webinar table. Ideally the span tag will be hidden if the date is cleared (right now if the date is cleared, it defaults to today's date).  I've figured out how to do this for another hubl module (eg: if button text is empty, hide button), but since this one is pulling data directly from a table that method doesn't quite work.  I have included my table loop below.  I think this can be done with an if statement, but I'm pretty new to hubdb table loops, so any help will be much appreciated. Thanks! (edited to show the english version of this table)

 

 

	{% for item in webinars %}

			<div class="col-4">
				<div class="card">
					<div class="card-thumbnail">
						<img src="{{ item.image.url }}" alt="">
					</div><!--card-thumbnail end-->
					<div class="card-info">
						<span class="date">{{ item.date|datetimeformat('%B %e, %Y') }}</span>
						<h2>{{ item.name }}</h2>
						<div class="summary">{{ item.summary }}</div>
						<a href="{{ item.link }}" title="" class="lnk-default">Agenda</a>
					</div><!--card-info end-->
				</div><!--card end-->
			</div>
			{% endfor %}
		</div>

 

 

0 Upvotes
1 Accepted solution
webdew
Solution
Guide | Diamond Partner
Guide | Diamond Partner

Hide a table row/cell if it is empty

SOLVE

Hi @pixelilly ,

Create Boolean option and add Somthing like this:

{% if item.hide_dates %}
{{ item.date|datetimeformat('%B %e, %Y') }}
{% endif %}

Client can easliy manange date hide show accordingly.


Hope this helps!
If we were able to answer your query, kindly help the community by marking it as a solution.

Thanks and Regards. 

View solution in original post

0 Upvotes
8 Replies 8
webdew
Solution
Guide | Diamond Partner
Guide | Diamond Partner

Hide a table row/cell if it is empty

SOLVE

Hi @pixelilly ,

Create Boolean option and add Somthing like this:

{% if item.hide_dates %}
{{ item.date|datetimeformat('%B %e, %Y') }}
{% endif %}

Client can easliy manange date hide show accordingly.


Hope this helps!
If we were able to answer your query, kindly help the community by marking it as a solution.

Thanks and Regards. 

0 Upvotes
pixelilly
Participant | Platinum Partner
Participant | Platinum Partner

Hide a table row/cell if it is empty

SOLVE

Yep, I've included a screenshot. Screen Shot 2021-05-19 at 10.33.27 AM.png

0 Upvotes
jonchim
Guide | Diamond Partner
Guide | Diamond Partner

Hide a table row/cell if it is empty

SOLVE

Wait maybe I misunderstood the initial post, do you want to hide everything if there is no date selected in HubDB? or just the date wrapped in the span?






Jon Chim
VP of Design & Development
Hypha HubSpot Development


check Did my post help answer your query? Help the Community by marking it as a solution
pixelilly
Participant | Platinum Partner
Participant | Platinum Partner

Hide a table row/cell if it is empty

SOLVE

That also hid it. I feel like it should be if is not empty but the syntax is tripping me up. 

0 Upvotes
jonchim
Guide | Diamond Partner
Guide | Diamond Partner

Hide a table row/cell if it is empty

SOLVE

Hmm interesting, are you using the date picker in the hubdb table? 






Jon Chim
VP of Design & Development
Hypha HubSpot Development


check Did my post help answer your query? Help the Community by marking it as a solution
pixelilly
Participant | Platinum Partner
Participant | Platinum Partner

Hide a table row/cell if it is empty

SOLVE

That almost worked! It hid the date even though there was data in the table cell.  

0 Upvotes
jonchim
Guide | Diamond Partner
Guide | Diamond Partner

Hide a table row/cell if it is empty

SOLVE

Got it! can you try row.date instead of item?






Jon Chim
VP of Design & Development
Hypha HubSpot Development


check Did my post help answer your query? Help the Community by marking it as a solution
0 Upvotes
jonchim
Guide | Diamond Partner
Guide | Diamond Partner

Hide a table row/cell if it is empty

SOLVE

Hey @pixelilly,

 

I think If statment is definitely the way. Can you give this a shot and see if this works? 🤞

 

 

{% if item.date  %}
<span class="date">{{ item.date|datetimeformat('%B %e, %Y') }}</span>
{% endif %}

 

 






Jon Chim
VP of Design & Development
Hypha HubSpot Development


check Did my post help answer your query? Help the Community by marking it as a solution