We have a page that is in dev.
It is working how we want apart from the need to hide the results until a selection is made.
Everything shows until a State is selected then it shows the right data.
I cant find anything online about this and wonder how it can be achieved?
Any help appreciated
Hey @StuGoymerIWD,
Based on this community thread, @Jsum recommended three options:
1. Using the url and queries.
2. Using Ajax.
3. Using jquery filter.
I would think that option 1 is the cleanest in which you can set the page to display none when the url query points to e.g. &country=null
What do you think?
Thank you for the reply
You refer to this:
1. using the url and queries. You would need to append the filter to the url and reload the page. Collect the query in a HubL variable. use the query to filter the database which would output items the correspond to the filter.
I’m not seeing anything there that helps as I could do with seeing code or an example of this to understand it properly.
The page still shows all results with Take Action to Protect America's Arctic (Im using name not country field)
It sounds like it is an IF statement in Hubl, but I would like to see an example if possible?
I am still getting NOWHERE with this. In all the tutorials, docs, the forum and me asking in Slack there is nothing that tells you how to display nothing until after you make a selection.
I would have thought that was pretty basic and someone esle would have asked - but I’m finding it impossible to figure out.
If I could even show just one result by default that would work. Thought the code below would do it but no.
{% set queryparam = “” %}
{% if request.path == “/take-action/” %}
{% set queryparam = queryparam ~ “&name=Alaska” %}
{% endif %}
Can no one help me with this?
Hey @StuGoymerIWD.
I research further into this and saw this community thread: Solved: HubSpot Community - Pagination for table rows of hubDB - HubSpot Community in which one of jzilch suggestion is to set a CSS (display:none) to hide the result at first:
“Once we have this setup we can then create our table with something like the below. We would be adding in the additional class and then we could set a style in CSS to hide the table rows such as tr { display: none; } and then for the items that we want to display we can add a class of active which would change the display to block and this would display the “ next page” and then hide the “previous page”. I won’t go too much into the JS Solution as this would be straightforward JS and adding the active class and running that function on a click event to change the CSS attribute.”
Do you think something like this may work for your page?
The solution is this:
{% if !request.query_dict %}
{% set queryparam = “&name=dummy” %}
{% endif %}
So if nothing is selected, then show the URL with nothing (=dummy) and then nothing will show. But guess what, were not out the woods yet.
As Hubspot CTA’s add code to URL’s for tracking and that then breaks the above code
/take-action?hsCtaTracking=
Its the primary CTA page so we cant not track it. I’ll create a new post to see if that can be resolved