Hi All,
My products are categorised into six collections - each collection has a page where all the respective items are displayed (these are dynamic pages). I have a dynamic product page that visitors access when they press on one of the items on the collection. On the item page, I have a ‘previous’ and ‘next’ that allows users to navigate through the products in each collection.
I am trying to add a ‘back to collection’ button that will allow visitors to go back to the appropriate dynamic collection page they started from.
Bellow the code I used for the ‘previous’ and ‘next’ buttons - this code works but I would like to add the ‘back to collections’ button.
$w.onReady( function () {
$w(“#previous”).disable();
$w(“#next”).disable();
if (local.getItem(‘dynamicPageURLs’)) {
const dynamicPageURLs = local.getItem(‘dynamicPageURLs’).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();
}
}
} );
Anyone have an idea on how to do this?