Is it possible to click a button on one page and have it filter a repeater on another page and redirect you to it?
I have a menu page with four buttons; if a user clicks a button I would like that user redirected to a dynamic page I have already setup… and have it filter that repeater to a value I have assigned - Is this possible?
On the first page I pass the parameter through the URL.
On the destination page I use the query function to retrieve the data from the url and then filter the repeater. You could also do it by using the wix-storage API.
Thank you Shan.
I see you did it as a drop down selector… have you tried it as a simple button?
Would it be possible to use the wix-storage to store a set filter for the ‘shop here’ button along with the location url - then on the destination page retrieve the query from wix-storage and filter the repeater.
I’m on my phone at the moment but later on I can send pictures to help explain myself.
So the ‘shop’ button is the one I would like to assign to. Each ‘shop’ button would have an assigned value, and once clicked that value would be stored in wix-storage and have the assigned URL to link to the destination page. (below)
This dynamic page has already been setup and works so that for each button pressed: CLEANSE, HYDRATE, MOISTURIZE & REFRESH - it already filters the repeaters exactly as I would like, but moving on…
The hydrate ‘shop’ button on the menu page is pressed, it brings you to the destination page above… retrieves the value from wix-storage and filters the repeater to only show HYDRATE - Is this at all possible or would I have to use a dropdown selector?
What I’m going to write is a little advanced so you might not be able to grasp it by just copy pasting, you’ll need to study the code and the links I have given along with it.
On your 1st page code each ‘shop’ button to redirect to the dynamic page along with the parameter in the URL.
export function shopCleanse_click(event) {
wixLocation.to(`https://www.domain.com/pageName?keyword=Cleanse`);
}
export function shopHydrate_click(event) {
wixLocation.to(`https://www.domain.com/pageName?keyword=Hydrate`);
}
I’m using the Wix Location API in the above code, read more about it here
Then on your Dynamic Page (assuming that you already have the filter functions) fetch the parameter’s value from the URL and run the filter like this
export function dataset1_ready() {
getLinks();
}
function getlinks() {
let keyword = wixLocation.query["keyword"];
if(keyword) {
filter(keyword);
}
}
You’ll see that I’m running the function under the dataset’s onReady function to allow the dataset to load prior to running the filter.
Then using wixLocation.query function I am retrieving the parameter from the URL.
After this I check if the URL’s parameter contained a value or not. If it did then I run the filter function using the value.
Seriously Shan… thank you! It’s actually pretty easy to follow by reading what you wrote, but I wouldn’t have been able to come up with that so thank you!!