Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hello,
I only have 1 global filter on the site. I would like users to be able to change the global filter using two different methods.
when a user clicks a link
or
When a user selects an item from a dropdown list
Can I assign the global filter with javascript?
onclick="myFunction(ChangeGlobalFilter)"
Thanks!
Comments
Comment #1
AgentJay CreditAttribution: AgentJay commentedI see it is possible to have the filter in the URL, so I can append it to the Link the user selects, but I would prefer if the user did not see the query in the URL.
Comment #2
RdeBoerYou can use the option "Suppress URL parameters in the links of the links widget" for that.
See the Global Filter configuration page admin/config/content/global_filter
Comment #3
AgentJay CreditAttribution: AgentJay commentedThanks for the heads up! I missed that option.
do you know if it is possible to include a query as the filter value?
IE. Setting the filter to:
?field_filter=filter_value&option1=something&option2=something_else
The filter value would be "filter_value&option1=something&option2=something_else"
instead of just filter_value
Thanks for the great module.
Comment #4
RdeBoerRe #3:
Yes, see the Q&A on the project page:
Q: Is there an easy way to reset all global filters and/or reset a specific global filter?
A: Yes. Append ?clear-global-filters or ?clear-global-filters=filter_name1,filter_name2 to the URL in the browser address bar. You can also create links on your site to do this e.g. <a href="/?clear-global-filters">Clear filters</a> embedded anywhere on your site will take the visitor to the home page while also clearing all global filters to their global defaults as configured on their block configuration pages.
Q: Can I create links on my site, in an email or on another site, pointing to pages on my site AND setting one or more global filters at the same time?
A: Yes and here's an example: <a href="http://mysite.com.au/music?field_period=sixties&keys=Beatles">Articles about the Beatles in the sixties</a>. This example assumes your site features a global filter for field_period (with an index "sixties"), as well as one for a search term.
Rik