Blog, Website & Page Publishing

Priyanka178
Participant

How to show listing of single column data from hubdb table with conditional base in module

I want to select people name with active people(active=true) from hubdb in module fields Hubdb row. Here name and active are two column name from Hubdb table name 'peoples'.

0 Upvotes
3 Replies 3
Indra
Guide | Elite Partner
Guide | Elite Partner

How to show listing of single column data from hubdb table with conditional base in module

Hi @TiphaineCuisset thanks for mentioning.

 

Hi @Priyanka178,

 

So you only want to display people with the active state of 'active' that is true right?

I have made an example HubDB with columns 'name' and 'active' as an checkbox field.

Schermafbeelding 2022-03-07 om 09.47.14.png

 

To render the HubDB you should use the hubdb_table_rows() function.

More info about the query parameters can be found over here.

{# Set the HubDB ID or name. #}
{% set db = '<tableID or name>' %}
{# Set query parameters and display only active people #}
{% set queryparam = '&active=true' %}
{# Set rows #}
{% set rows = hubdb_table_rows(db, queryparam) %}

{% for row in rows %}
  {{ row.name }}
  <hr>
{% endfor %}

 

This will output the following:

Schermafbeelding 2022-03-07 om 10.01.12.png


Vet Digital - The Growth Agency | HubSpot Solutions Partner Agency

Did my post solve your question? Help the community by marking it as a solution
Deepika9041
Member

How to show listing of single column data from hubdb table with conditional base in module

Hey

Can you please tell me if I want to show selected rows data on listing page so how to do it?
I added a column named as "Main Listing order" in hubdb table in which i added numbers from 1 to 6 so that the listing shown according to this column


<div class="boxlayout-listing">
{% if dynamic_page_route_level == 0 %}
{% set array = [] %}
{% set table_categories = hubdb_table_rows(dynamic_page_hubdb_table_id) %}
{% for row_category in table_categories %}
{% set subcategories = hubdb_table_rows(row_category.hs_child_table_id) %}
{% set table_data = hubdb_table_rows(row_category.table_id, "orderBy=main_listing_order", order="order ASC") %}

<div class="templates_head">
<h2 class="click-category main-listing-title">
{{row_category.name}}
</h2>
<a href="/templates/c/{{ row_category.hs_path }}" id="{{ catId }}" class="see_all">
View all<i class="fa fa-long-arrow-right" aria-hidden="true"></i>
</a>
</div>
{% set obj = {val : 0} %}
<ul class="template-list-view ">
{% for row in table_data %}
{% for choice in subcategories %}
{% for cat in choice.category_name%}
{% for sub in row.subcategory_name %}
{% if sub.name == choice.name and cat.name == row_category.name %}
{% if row.hs_id in array %}
<div style="display:none">exist id - {{ row.hs_id }} - {{ array }}</div>
{% else %}

{% if ( obj.val < 6) %} {% do obj.update({val: obj.val + 1 }) %} {% do array.append( row.hs_id) %}
<li>
<div class="templates_card">
<img src="{{ row.Image.url }}" alt="{{ row.name }}" />
<div class="stay-component">
<h4>{{ row.name|truncatehtml(60, '...', false) }}</h4>
{{row.description|truncatehtml(100, '...', false)}}
</div>
<a href="/templates/{{ row.hs_path }}" id="{{ catId }}">ViewMore</a>
</div>
<div style="display:none">{{array}}</div>
</li>
{% endif %}
{% endif %}
{% endif %}
{% endfor %}
{% endfor %}
{% endfor %}
{% endfor %}
</ul>
{% endfor %}
{% endif %}

</div>

The  above is current code but it hides the listings in which I assign the value instead of showing.

Thanks
Deepika



Deepika9041_0-1689323993392.png

 

0 Upvotes
TiphaineCuisset
Community Manager
Community Manager

How to show listing of single column data from hubdb table with conditional base in module

Hi @Priyanka178 

 

Thank you for reaching out.

 

I want to tag some of our experts on this - @Kevin-C @Indra @Mark_Ryba do you have any advice for @Priyanka178 on this?

 

Thank you!

Best

Tiphaine


Saviez vous que la Communauté est disponible en français?
Rejoignez les discussions francophones en changeant votre langue dans les paramètres !

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


0 Upvotes