However we would like the tag selector to display between the widget header (in this example “Events”) and the widget results. Currently it is displaying above the header.
(The default tag selector floats on the right of the initial widget results, and we have so far styled it to be horizontal across the top.)
Thanks. I didn’t include in the original post to keep things succinct… but the reasoning for trying to find a solution beyond, say, your first suggestion (aka, don’t include the header in the widget) was for the cases where someone has a widget with no results; so there’d be a sad header with nothing under it. Still I appreciate and will try your solutions.
That makes sense. I was assuming this was a one-off widget that could reasonably be expected to have content in it. The JS solution should still work. Just throw that script in your global theme JS.
Thanks Jon – I’ll raise here since it’s related, we’ve recently retired the widget “slideshow” JS behavior in LW3 given that most site builds are using some sort of existing slideshow plugin rather than needing out-of-the-box handling of this.
Similarly, we’ve seen folks using existing JS libraries like isotope for this kind of click-to-filter behavior, too, so I wouldn’t be surprised to see the tag selector widget option being retired in LW3 as well—if that’s the case, it’ll be spelled out clearly in the upgrade guide and we’re happy to help point towards other ways of handling (which would then be a bit more flexible than the single on/off switch the core version has supplied).
In that filterable widget, the individual programs are tagged with data- attributes for each selector, e.g. <a class="program-card" data-select-level="Major" data-select-subjectarea="Performance and Theatre Arts" data-select-degree="BFA" data-select-tags=""> and then there’s JS that gathers up all the possible data- values on page load and creates the dropdowns. (Wouldn’t have to be done with dropdowns, of course, that’s just a design choice. Could be buttons or toggles or whatnot).
To clarify: the beauty of the Tag Selector tool is it can be added to nearly any widget and automatically work; whereas, the sorting tool we have on places like the Community Profiles link mentioned previously is manually built (with hard-coded “data-select-” for each field) each time we need it.