CMS Development

cives
Contributor

HubDB Listing Page By Month

SOLVE

Hi all — I'm working on a listing page that separates all HubDB rows by month (picture below):

Screen Shot 2020-06-24 at 9.24.04 AM.png

 

I'm currently looping through the table several times to achieve this structure, though the way I'm doing it isn't the cleanest, especially for querying:

 

<h2 class="pt-10">January 2016</h2>
{% for row in hubdb_table_rows(2638818, queryparam) %}
{% if (row['publish_date']|datetimeformat('%m/%d/%Y')) == '01/01/2016' %}
<p><a href="{{ request.path }}/{{ row.hs_path }}">{{ row.hs_name }}</a> - <span><i>By: {{ row.author.name }}</i></span></p>
{% endif %}
{% endfor %}

<h2 class="pt-10">February 2016</h2>
{% for row in hubdb_table_rows(2638818, queryparam) %}
{% if (row['publish_date']|datetimeformat('%m/%d/%Y')) == '02/01/2016' %}
<p><a href="{{ request.path }}/{{ row.hs_path }}">{{ row.hs_name }}</a> - <span><i>By: {{ row.author.name }}</i></span></p>
{% endif %}
{% endfor %}
            
<h2 class="pt-10">March 2016</h2>
{% for row in hubdb_table_rows(2638818, queryparam) %}
{% if (row['publish_date']|datetimeformat('%m/%d/%Y')) == '03/01/2016' %}
<p><a href="{{ request.path }}/{{ row.hs_path }}">{{ row.hs_name }}</a> - <span><i>By: {{ row.author.name }}</i></span></p>
 {% endif %}
{% endfor %}

What would the markup look like using just one loop? 

 

 

0 Upvotes
1 Accepted solution
Jsum
Solution
Key Advisor

HubDB Listing Page By Month

SOLVE
2 Replies 2
sharonlicari
Community Manager
Community Manager

HubDB Listing Page By Month

SOLVE

Hey @cives 

 

Thank you for the information provided.I'll tag a few experts that can share their experience with you.    

 

Hey @Jsum @Reg @Adesignl  any thoughts you would like to share with @cives?   

 

Thanks & Happy Friday

 

Sharon


Did you know that the Community is available in other languages?
Join regional conversations by changing your language settings !




0 Upvotes
Jsum
Solution
Key Advisor

HubDB Listing Page By Month

SOLVE