CMS Development

leckerman
トップ投稿者

hubdb column in as a choice dropdown in custom module

解決

Can anyone tell me how to create a HubDB filter as a "choice field" in a custom module instead of filtering on the page itself (like the one on this page -http://www.alignex.com/training-classes)?

 

What does the "value" for the choices in the widget need to be so it reference a column and drop down choice in a HubDB table.

 

Would it be something like this or does the table id need to be listed here rather than in the code?

 

Widget Name: {{ widget.select_course }}

Value: "<Insert HubDB Column Name>=1"   Label:"3D CAD"

Value: "select_course=2"   Label:"Simulation"

Value: "select_course=3"   Label:"Electrical"

 

Where do you insert {{ widget.select_course }} into the code so it is dynamic based on the course that meets the "Value" selected?

 

0 いいね!
1件の承認済みベストアンサー
leckerman
解決策
トップ投稿者

hubdb column in as a choice dropdown in custom module

解決

@scottrief - I just had a breakthrough on this! Figured I would share if you are still interested.

 

These are my three choice options I put into the custom module choice field. Note the red 1, 2 and 3 are the option ids that correspond to the column choices in my hubdb table. Hope this helps! 

 

{% set queryparam = "&orderBy=date&course=1" %}

{% for row in hubdb_table_rows(<tableId>, queryparam) %}
{% if (row['date']|datetimeformat('%j'))>=(local_dt|datetimeformat('%j'))%}
  <p><strong>Course Name: </strong>{{ row["course"].name }} <br>
  <strong>Date: </strong>{{ row.date|datetimeformat('%A, %B %e, %Y') }}<br> 
  <strong>Location:</strong> {{ row.class_location }}</p>
{% endif %}
{% endfor %}


{% set queryparam = "&orderBy=date&course=2" %}

{% for row in hubdb_table_rows(<tableId>, queryparam) %}
{% if (row['date']|datetimeformat('%j'))>=(local_dt|datetimeformat('%j'))%}
  <p><strong>Course Name: </strong>{{ row["course"].name }} <br>
  <strong>Date: </strong>{{ row.date|datetimeformat('%A, %B %e, %Y') }}<br> 
  <strong>Location:</strong> {{ row.class_location }}</p>
{% endif %}
{% endfor %}


{% set queryparam = "&orderBy=date&course=3" %}

{% for row in hubdb_table_rows(<tableId>, queryparam) %}
{% if (row['date']|datetimeformat('%j'))>=(local_dt|datetimeformat('%j'))%}
  <p><strong>Course Name: </strong>{{ row["course"].name }} <br>
  <strong>Date: </strong>{{ row.date|datetimeformat('%A, %B %e, %Y') }}<br> 
  <strong>Location:</strong> {{ row.class_location }}</p>
{% endif %}
{% endfor %}

 

元の投稿で解決策を見る

0 いいね!
3件の返信
scottrief
メンバー

hubdb column in as a choice dropdown in custom module

解決

Were you able to figure this out? I have a similar need for use in a Custom Module.

0 いいね!
leckerman
トップ投稿者

hubdb column in as a choice dropdown in custom module

解決

Hi @scottrief,

 

No I wasn't able to figure this out. I was told in a different post to try something like this... but still wasn't able to make it work. Maybe you could try?

 

{% set col = hubdb_table_column (674971, <columnId>) %} 

{% set select_course = col.getOptionByName("Essentials") %}

{{ select_course }}

 

0 いいね!
leckerman
解決策
トップ投稿者

hubdb column in as a choice dropdown in custom module

解決

@scottrief - I just had a breakthrough on this! Figured I would share if you are still interested.

 

These are my three choice options I put into the custom module choice field. Note the red 1, 2 and 3 are the option ids that correspond to the column choices in my hubdb table. Hope this helps! 

 

{% set queryparam = "&orderBy=date&course=1" %}

{% for row in hubdb_table_rows(<tableId>, queryparam) %}
{% if (row['date']|datetimeformat('%j'))>=(local_dt|datetimeformat('%j'))%}
  <p><strong>Course Name: </strong>{{ row["course"].name }} <br>
  <strong>Date: </strong>{{ row.date|datetimeformat('%A, %B %e, %Y') }}<br> 
  <strong>Location:</strong> {{ row.class_location }}</p>
{% endif %}
{% endfor %}


{% set queryparam = "&orderBy=date&course=2" %}

{% for row in hubdb_table_rows(<tableId>, queryparam) %}
{% if (row['date']|datetimeformat('%j'))>=(local_dt|datetimeformat('%j'))%}
  <p><strong>Course Name: </strong>{{ row["course"].name }} <br>
  <strong>Date: </strong>{{ row.date|datetimeformat('%A, %B %e, %Y') }}<br> 
  <strong>Location:</strong> {{ row.class_location }}</p>
{% endif %}
{% endfor %}


{% set queryparam = "&orderBy=date&course=3" %}

{% for row in hubdb_table_rows(<tableId>, queryparam) %}
{% if (row['date']|datetimeformat('%j'))>=(local_dt|datetimeformat('%j'))%}
  <p><strong>Course Name: </strong>{{ row["course"].name }} <br>
  <strong>Date: </strong>{{ row.date|datetimeformat('%A, %B %e, %Y') }}<br> 
  <strong>Location:</strong> {{ row.class_location }}</p>
{% endif %}
{% endfor %}

 

0 いいね!