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?
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 %}
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 }}
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 %}