Hi there! I’d like to create a link to my Work/portfolio page (with a dataset of portfolio items), but with only one of the selection filter tags selected. Is it possible to have a URL for each selection tag like this? Thanks in advance!
Hi there!
This is possible using the Wix Location Frontend API to use query parameters from the url as a filter selector.
The following is a example of how this can be done for a single filter when the page loads using a query parameter.
In this example, if the user loads the url:
https://www.domain.com/myPrefix/myPath?selection=Breakfast
The variable selected
will store the the value Breakfast
which can be used to set a selected option in a Selection Tag Element. You can then write code to handle loading and displaying the right data based on the selected tag.
Example
import wixLocationFrontend from 'wix-location-frontend';
$w.onReady(function () {
const selected = wixLocationFrontend.query.selection; //Checks for Query Parameter named "Selection"
if (selected) {
$w('#tags').value = [selected]; //Sets filter in a Selection Tag Element
//Handle Loading and Displaying Data based on Selection Tags
}
});
Try out the following Velo Example if you need a template to attempt implementing this feature: Filter With Multiple Options