I am currently running a project for a tour operator, I want to link the database as follows:
Continents Page > Countries Page > Locations Page > Hotel Brochure Page
e.g: Europe > England > London > London Hotel
How can I do this? Do I need multiple dynamic pages or multiple databases?
I need the location pages to show the two hotels from that specific location (location is a field in my database)
I need the hotel page to display up to 10 images in a carousel and also display the hotels description and room features.
At the minute my database looks like this:
Continent Country Location Hotel Description Image 1 Image 2 Image 3
and so on…
No, you do not need multiple databases or collections, your current setup is fine. To do a narrow down search as you proposed, you could do this using text links, with several dropdowns or with a free search. all using a repeater to show the end result. There is a video on this, with code, on Youtube.
Displaying 10 images is a no-brainer, just hook the images up to a gallery. If a hotel has less then 10 pictures, there will be grey boxes. Search the forum how to solve this problem (basically, create a new array with all available pictures and throw THAT at the gallery).
If you want to display geo-locations on a Google Map, Yisrael made a very good example (with code) in the “Tips and Trics” section. But you will need latitude and longitude per hotel in the collection.
Hi Giri,
Thanks for your reply, when I come to hook the gallery up I’m given options of ‘Image 1, Image 2, Image 3’ so on and so forth which pulls through the first/second/third image from EVERY hotel in my database. How do I set the gallery to only pull through images 1-10 of a specific row?
Thanks,
Thomas
You need code to do so. First, you will have to do a query per hotel to select that very row. Then, in a for-loop from 1 to 10 (assuming you started counting images from 0 and not from 1) you check if there is an image with:
let fieldname= “Image” + i; // assuming the counter in the for loop is called i, so it will return Image1, Image2, etc as the fieldname in the collection to retrieve
let strImage = $w(“#myDataset”). getCurrentItem()[fieldname];();
if (strImage) {
// push it to a new array
}
and if you have one, you .push the image to a new array (look at w3schools for the array.push syntax) and after the loop has ended, you hand that array to the gallery.