Controllable queryparam through choice field?

Hi,

I’m trying to build a Meet the Team module for our website. What I would like this module to do is sit on a page and only show a specific group of people. I have the database set up and the following code

{% for row in hubdb_table_rows(module.mtt_table, queryparam) %}{% if loop.index <= 8 %}<div class="profile-box text-center"><span><a class="no-underline diamond-ie" href="{{ request.path }}/{{ row.hs_path }}"><img class="diamond" src="{{ row.featured_image.url }}" alt="{{ row.first_name }} {{ row.last_name }}"></a><h4>{{ row.first_name }} {{ row.last_name }}</h4><p>{{row.job_title}}</p><p><a href="mailto:{{ row.email }}">{{ row.email }}</a></p></span></div>{% endif %}{% endfor %}

This works fine and displays all of our colleagues who have a profile set up in the HubDB.

In the HubDB, I have a column which is a multi-select “Expertise”. This holds information about what area our colleagues specialises in. In the module, I have set up a choice_field which has the exact same selection options as the column “Expertise” in the HubDB (same order too).

What is the best way to set the queryparam based on the choice_field selection?

Everything I have found so far only tells me how to add a filter than the user’s control, rather than the back end and per page.

Finally got it to work. Turns out I was over complicating the matter.

I was trying to compare the value of the choice_field to the injury ID. Instead, I threw a bunch of IF statements for each of the choice_field options and that worked fine.

{% set queryparam = "&orderBy=order" %}
{% if module.choice_field == "1" %}
{% set queryparam = queryparam ~ "&expertise__contains=1" %}
{% endif %}

{% if module.choice_field == "2" %}
{% set queryparam = queryparam ~ "&expertise__contains=2" %}
{% endif %}

{% if module.choice_field == "3" %}
{% set queryparam = queryparam ~ "&expertise__contains=3" %}
{% endif %}
{% set table = hubdb_table_rows(1053024, queryparam)%}
{% for row in hubdb_table_rows(1053024, queryparam) %}{% if loop.index <= 8 %}<div class="profile-box text-center"><span><a class="no-underline diamond-ie" href="{{ request.path }}/{{ row.hs_path }}"><img class="diamond" src="{{ row.featured_image.url }}" alt="{{ row.first_name }} {{ row.last_name }}"></a><h4>{{ row.first_name }} {{ row.last_name }}</h4><p>{{row.job_title}}</p><p><a href="mailto:{{ row.email }}">{{ row.email }}</a></p></span></div>{% endif %}{% endfor %}

.