Hay Yael,
Do you mean how to link from one dynamic page to another, say the previous or next one?
In order to do so, you need to first decide what is the ordering between dynamic pages (what is the sort order). Lets assume you want to order by tile. In this case, there are two steps to get a button to link to the next or previous item.
Step one - find the url of the next or previous item. You can do so using the Wix Data APIs
Step two - navigate to the next or previous page in the button on click handler.
The code for this looks kind of like the following
let nextLink;
$w.onReady(() => {
let currentItem = $w('#dynamicDataset1').getCurrentItem();
let title = currentItem.title;
wixData.query('my-collection')
.gt('title', title)
.limit(1)
.find()
.then((res) => {
if (res.length === 1)
nextLink = res.items[0].dynamicPageLink;
else
$w('#button1').hide();
});
});
export function button1_onClick(event) {
if (nextLink)
wixLocation.to(nextLink);
}
Note
-
The dynamic dataset name may be different from dynamicDataset1. Select the dataset and check the name in the property panel. You can also set another name there.
-
The name of the field for the link to the items may be different from dynamicPageLink. In the database view (content manager) open the popup menu for the link column, select field properties and checkout the field key. This is the value you need to use here.
-
If the item is the last item, we hide the button.
-
For the previous item, just change the .gt function to .lt (from larger then to lesser then).