Hello,
I created a dynamic item page and followed the instructions form the article below to create previous/next buttons, but I'm having issues with my urls in the code so the buttons are not working. Can I get some feedback on what I'm doing wrong here.
https://support.wix.com/en/article/how-to-create-previous-and-next-buttons-for-a-dynamic-item-page
Hi, I am trying to loop my previous and next button on a dynamic page. I am not a coder, hence unable to find out my mistake here. Can someone help me here. Should this code work for the purpose or should I change it. Thanks!
hi, i am having some issue with my next and previous button. i used the technique from https://support.wix.com/en/article/wix-code-tutorial-creating-previous-and-next-buttons-for-a-dynamic-item-page-with-code
for some reason the wixLocation.path.join ('/') only give me a value of yoursitename and not the info of the page i need.
this page work perfectly
but than i get stuck at getting the link with ^^'
can someone please help me?
Hi,
Can you specify the name of the page ?
Roi
Help!
https://www.saildaddy.com/NewZealand/Picton-Marina
I'm have some difficulties with adding a "Next button and a Previous button" on a single not a category Dynamic page. I just can't figure it out. I've followed steps #8 from the tutorial below and nothing happened
https://support.wix.com/en/article/tutorial-using-a-dataset-on-a-regular-page-to-display-content
8. Create Previous and Next Buttons
Now that all your elements are connected to the same collection through the same dataset, you need to allow your visitors to browse through the information. To do this, add two buttons to your page, connect them to the same dataset as the other elements, and define their click actions.
To create Previous and Next buttons:
Add two buttons to your page and change their texts to Previous and Next.
Click their Connect to Data 📷 buttons.
In the Connect Button panel, select your dataset.
Under Link connects to, select Previous for the first button and Next for the second button.
So I then followed the tutorial below and I'm confused and don't know what I'm supposed to add in
import {local} from 'wix-storage'; to resolve the error message on line 6? Also am I supposed to be on the site or the page when adding this code?
https://support.wix.com/en/article/how-to-create-previous-and-next-buttons-for-a-dynamic-item-page
Thank you for any help
I'm fine with that! I should just need a point in the right direction ^_^
Thanks so much Mikhail!
Cheers! 🍻
Yes, you should add more conditions -
if (currentPageIndex = 0) { ... set wixLocation.to to last item on prevButton ... }
if (currentPageIndex = dynamicPageURLs.length {... set wixLocation.to to first item on nextButton ... }
but i won't write code for you, i can only give you heneral idea how to achieve this
YAY! as expected, that fixed it. Thank You!
One final question.
Is there a way to loop the entries? So when you're on the first item, if you click the previous button it takes you to the last item. And if you're on the last item and you click the next button, it takes you back to the first item?
I honestly don't know know how that happened.... I thought I had copied it perfectly.... 😅😅😅
I'm sure it'll work but I'll let you know once I've confirmed.
Thank You Mikhail! Much Appreciated! xx
Hi! Found the problem
Why did you delete this part from original tutorial?)
tutorial -
const currentPage = '/' + wixLocation.prefix + '/' + wixLocation.path.join('/');
your site -
const currentPage = '/' + wixLocation.path.join('/');
This causes the issue.
It tries to find this -
/leafrielcoyle%40gmail.com
in this array -
/Member-Applications/testemail3%40gmail.com,/Member-Applications/testemail2%40gmail.com,/Member-Applications/testemail1%40gmail.com,/Member-Applications/leafrielcoyle%40gmail.com,/Member-Applications/jaded.rogue%40gmail.com
And it doesn't succeed, because there is no such item
Copied those and checking, so please delete
Yes, I wish there was a way to private message though. Please let me know when you no longer need the URLs, so I can delete them.
Index Page redacted url
Item Page redacted url
Hi! First thing is known and handled (apperaing erros for second)
Second is something strange, but looks like you don't have anyitems in your local storage
Is it possible to share link to your site here? I can check
I'm having the same problem. Followed the tutorial and my previous/next buttons are not working on my item page.
This is my code for review.
// INDEX PAGE import {local} from "wix-storage"; const linkField = "link-Member-Applications-emailText"; // replace this value $w.onReady(function () { $w("#MemberApps").onReady(() => { const numberOfItems = $w("#MemberApps").getTotalCount(); $w("#MemberApps").getItems(0, numberOfItems) .then( (result) => { const dynamicPageURLs = result.items.map(item => item[linkField]); local.setItem('dynamicPageURLs', dynamicPageURLs); } ) .catch( (err) => { console.log(err.code, err.message); } ); } ); } );
I got "link-Member-Applications-emailText" from the database, from the field that was auto-generated when I created and linked the Item page to my Index page.
// ITEM PAGE import {local} from 'wix-storage'; import wixLocation from 'wix-location'; $w.onReady(function () { $w("#prevButton").disable(); $w("#nextButton").disable(); if (local.getItem('dynamicPageURLs')) { let dynamicPageURLs = local.getItem('dynamicPageURLs').split(","); let currentPage = "/" + wixLocation.path.join('/'); let currentPageIndex = dynamicPageURLs.indexOf(currentPage); if (currentPageIndex > 0) { $w("#prevButton").onClick( () => { wixLocation.to(dynamicPageURLs[currentPageIndex - 1]); } ); $w("#prevButton").enable(); } if (currentPageIndex < dynamicPageURLs.length - 1) { $w("#nextButton").onClick( () => { wixLocation.to(dynamicPageURLs[currentPageIndex + 1]); } ); $w("#nextButton").enable(); } } });
Something strange happens and I'm not sure if it's related, in the editor when I open the page code, it shows the little error icons beside the line numbers, then it disappears once I click in the code.
Okay, so upon further inspection, I have found that the next button works but no matter which item you are viewing, the button takes you to the first item in the dataset.
Hi Yvette,
'local.setItem' accepts two parameters, the first one is a 'Key' and the second one is 'Value'.
In the article, they have the following line:
const dynamicPageURLs = result.items.map(item => item[linkField]); local.setItem('dynamicPageURLs', dynamicPageURLs);
Which actually sets the Key named 'dynamicPageURLs' to be an array of URLs (which is what you get when calling 'result.items.map' if the previous line).
Hope this helps,
Liran.
Hello Ido,
Thank you for the advice. That cleared up the "local" error. However I am still having issues with the "https". Did I copy the url incorrectly?
incorrectly?
Hello Yevette,
Are you importing local from Wix-storage?
import {local} from "wix-storage";