I was wondering if anyone has any idea of where to start with trying to filter a repeater to show ‘related courses’? I’m not even sure where to start! I have a little coding experience and would expect it would need to be done through code. Any ideas?
Can you explain what you mean by related items? because if you just want to filter specific items going through the data set is best. If you press the data set then go to manage set there is a filter option. It can filter any field to contain or not contain what you want. If you provide the url that would be helpful too.
Hi Elizabeth,
I will try and explain with a little more clarity, If the user is viewing a course say ‘intro to climbing’ then on the bottom of the page there is a repeater that I would like to display 3 ‘related courses’ i.e. ‘improver rock climbing’ ‘sea cliff climbing intro’ and so on.
This is on a dynamic page, so if the user is viewing a different course i.e. ‘hiking holidays’ then there will be 3 related courses from the dataset for hiking Holidays, and for what ever course they are viewing there will be 3 similar courses displayed in the repeater, I hope this makes more sense?
I have tried to use the filter, but can’t get the courses to show as ‘related’ to the current course. Here is the URL if it helps https://www.scottishrockandwater.com/Courses/Rock-Climbing/Intro-to-Rock-Climbing
as you can see at the bottom of the page, there are 3 courses but they are for canoeing as this is only what I have managed to filter and have something there to start.
I thought it would need to be coded, but not sure where to start with this one…
Hi,
You can find an example here of filtering Repeater using some code. I hope it’ll help.
Good luck,
Tal.
Hi Tal,
Thank you for the info, I’m making progress and have linked everything to the repeater, I’m just wondering how to filter using the URL? i.e. if the user navigates to
how to I get the repeater to show only courses that within the dataset have the term ‘scrambling’ and so on? I know I will have to reference the field key ‘coursesCategory’ within the ‘Courses’ dataset but not sure how to go about this with a URL being involved.
This is the current code
import wixData from 'wix-data';
import wixLocation from 'wix-location';
let Courseresults = [];
$w.onReady(function () {
wixData.query("Courses")
.find()
.then((results) => {
Courseresults = results.items;
$w('#repeater1').data = Courseresults;
})
.catch((err) => {
let errorMsg = err;
});
$w('#repeater1').onItemReady(($w, itemData) => {
$w('#button1').label = itemData.title;
$w('#image41').src = itemData.grade;
$w('#image40').src = itemData.image;
$w('#text159').text = itemData.duration;
$w('#text93').html = itemData.details;
$w('#text157').text = itemData.individaulPrice;
});
});
export function image40_click(event, $w)(event, $w) {
wixLocation.to("link-Courses-title-coursesCategory");
}
Many thanks in advance
Hi,
You can query the collection and check whether a field has a specific value. Click here to learn more about the query function. Click here to learn more about the data query options. You can use include for querying records with reference field. Click here to learn more about it.
Good luck!
Tal.