Hi again,
I created a sample site and transferred it to your account, so you can take a look how everything connects together. In order for the navigation to work properly, publish the site first - this will allow you to better test the item navigation in the editor.
I did what I wrote a few posts earlier:
- Created a “Countries” collection with country name, continent and image
- Created a regular “countries” page with 2 galleries, each filtered according to the continent
- Save the URLs from both galleries under a unique key for each gallery
- When an image in one of the galleries is clicked, I also save that gallery key to the local storage.
- In the single country item page, the code takes the URLs according to the last selected gallery key.
Here’s the code for the index page:
import {local} from "wix-storage";
const linkField = "link-Countries-title";
$w.onReady(function () {
setUrls('#africaDataset', 'africa');
setUrls('#europeDataset', 'europe');
});
function setUrls(datasetSelector, galleryCategory) {
$w(datasetSelector).onReady(() => {
const numberOfItems = $w(datasetSelector).getTotalCount();
$w(datasetSelector).getItems(0, numberOfItems)
.then( (result) => {
const dynamicPageURLs = result.items.map(item => item[linkField]);
local.setItem(galleryCategory, dynamicPageURLs);
})
.catch( (err) => {
console.log(err.code, err.message);
});
});
}
export function galleryAfrica_click() {
local.setItem('selected-gallery', 'africa');
}
export function galleryEurope_click() {
local.setItem('selected-gallery', 'europe');
}
Here’s the code for the country item page:
import {local} from 'wix-storage';
import wixLocation from 'wix-location';
$w.onReady(function () {
$w("#previous").disable();
$w("#next").disable();
const selectedGallery = local.getItem('selected-gallery');
if (selectedGallery) {
const dynamicPageURLs = local.getItem(selectedGallery).split(',');
const currentPage = '/' + wixLocation.prefix + '/' + wixLocation.path.join('/');
const currentPageIndex = dynamicPageURLs.indexOf(currentPage);
if (currentPageIndex > 0) {
$w("#previous").link = dynamicPageURLs[currentPageIndex - 1];
$w("#previous").enable();
}
if (currentPageIndex < dynamicPageURLs.length - 1) {
$w("#next").link = dynamicPageURLs[currentPageIndex + 1];
$w("#next").enable();
}
}
} );

