I have a webpage where I have a dynamic page which shows a list of Hotels, there I will have a button “info” whcih then links to another page which shows details of a singele hotel. the final detailled Hotelpages are static, because several parts in this page I can´t build in a dynamic page (more than one foto of the hotel - i would like to have a gallery there) as well price tables. How do I have to setup the URL whcih I add to the database so that it redirects to the final page?
Hello
In that case if you want to link to different static pages from the dynamic page you do the following:
-
add a field to the data base ‘link’
-
in that field add the link for the hotel page, ex: /Hotel-1.
-
on the page click on the button properties and add on button click event
-
on this event get the current item, and link to the link field using wix location:
export function button1_click(event, $w) {
//Getting the current item link from dataset
let link = $w('#repeaterData').getCurrentItem().link
//Using wixLocation API to redirect to that link that we got
wixLocation.to(link)
}
check wixLocation documentation -here. and the data set getCurrentItem -here.
But as I understood from your question is that you’re using the static linking because of the gallery issue. If that’s the case then the following suggestion will help you solve it.
assuming that when clicking on the button it will direct the user to the dynamic hotel-details page, in order to show the gallery with the right images on that page do the following:
-
onReady get the current item data from the dynamic data set (the result will be one object)
-
change that object to an array using Object.values() method (the result will be an array of all the items field)
-
search the resulting array for elements that start with image and push the result in a new array(the result will array containing all the image items)
-
now turn the array into object in the format of the gallery items array -here
-
set your gallery items to the final objects array!
I hope this help!
Massa
thank you very much for your fast and detailled response I´ll try it.