On my real estate website’s Properties for Rent page ( https://bdarienjr.wixsite.com/tmt-realty/rentals-1 ), I have a repeater connected to 2 datasets - one is the for the properties and the other is for the rental units inside the properties. The rentals dataset is the dynamic dataset.
Some properties have multiple units available for rent. Currently, all available units for a property display on the page. My goal is to have only one “unit” display on the Properties for Rent page - when someone clicks on that unit, they are taken to the dynamic (title) page for that property (e.g. https://bdarienjr.wixsite.com/tmt-realty/properties/5108-S-CALUMET-AVE ), which will display all units currently available (see screenshots below).
From viewing the properties page, it looks like you have one record in the properties collection for each rental unit. Is that right? If that is the case and there are good reasons for keeping it that way, there is a wixData query function called distinct that could return the unique property addresses. That would, of course, require you to populate the properties repeater via code and not via a dataset. You may or may not have a comfort level with doing that.
The alternative, if you would like to stay with the dataset approach, would be to restructure your database to make it a one-to-many relationship between properties and rental units.
In any case, a screen shot of the properties collection would provide a clearer idea of your data structures and requirements.
Thank you! I would definitely like to stick with the dataset approach. Could you please explain a little bit more about what a “one-to-many relationship” is and how to create it? Here is a screenshot of the Properties collection:
In effect, you are using one-to-many since you have one property record with multiple rentals in a reference field. Nothing to suggest there.
Like you, I’m left wondering why you would have duplicates in the repeater on your property page. How is that set up? Is it a dataset connected to the properties collection which is in turn connected to the repeater?
I have 2 datasets - 1 connected to Rentals (dynamic dataset) and 1 connected to the Properties dataset.
The repeater is connected to the Rentals dataset, with some components displaying information from the Rentals dataset about the specific unit and other components linked to the dynamic property (title) page through the Properties dataset.