CMS Development

leckerman
Top Contributor

HubDB filter if statement help

I am having a hard time trying to figure out how to write a couple different if statement for two filters in a HubDB custom module. Any help would be appreciated.

 

I have a two filters...

Type of Event = Event ("1)", Webinar ("2")

Location of Event = Minnesota ("1"), Wisconsin  ("2"), Colorado ("3"), Iowa ("4"), North Dakota ("5")

 

If someone chooses "Show All" OR "Webinar" for the "Type of Event" and any of the options for the "Location of Event", I want all of the webinars to show up. The webinars are not location specific, so I want all of them to show up in the search results unless the "Type of Event" is selected as "Event."

 

Here are the current if statements I have in place that do not address this...

 

<!-- sets the different query parameters using submitted input for hubdb query -->
{% set typequery = "&orderBy=event_date_start" %}
{% if request.query_dict.type in ["1", "2"] %}
{% set typequery = typequery ~ "&type="~request.query_dict.type|urlencode %}
{% endif %}
{% if request.query_dict.type == "show-all" %}
{% set typequery = typequery %}
{% endif %}
{% set locationquery = "&orderBy=event_date_start" %}
{% if request.query_dict.location in ["1", "2", "3", "4", "5"] %}
{% set locationquery = locationquery ~ "&location="~request.query_dict.location|urlencode %}
{% endif %}
{% if request.query_dict.location == "show-all" %}
{% set locationquery = locationquery %}
{% endif %}

0 Upvotes
2 Replies 2
roisinkirby
HubSpot Product Team
HubSpot Product Team

HubDB filter if statement help

Hey @leckerman are you still experiencing this roadblock? If so I'll connect you with some of our HubDB experts 🙂

0 Upvotes
leckerman
Top Contributor

HubDB filter if statement help

I found a work around for this instead. I switched it to one filter (instead of two) and added a "Virtual" category to "Locations" for webinars. Never figured it out, but found a different way that is working for me instead. Thanks!

0 Upvotes