I’ve read the post about next and previous buttons not working on the single item pages, only on category pages. I did not understand how to get this to work. How then, when viewers have opened a single item page from the category page, do they move on to the next item? I need them to scroll from one plant page to the next without having to go back to the category page. How do I add a quick return link to the category page from each item page?
Hi,
When using a dynamic item page the next and previous buttons do not work because the page’s dataset has only one item in it. So there is no “next” or “previous” item.
There are three ways to work around this.
-
Use a regular page as described in Tutorial: Using a Regular Page to Display Content . Depending on what items you want to show, this may be more complicated to set up than a dynamic page, but it will give you working next and previous buttons.
-
Use a dynamic item page and code your own next and previous buttons. You can see some code examples in this post: https://www.wix.com/code/home/forum/questions-answers/what-is-wrong.
-
Use a dynamic category page, but only show one item at a time (i.e. do not use a table or gallery). The downside to this approach is that each item does not have its own URL.
Ah, thanks so much, Sam. Now I understand. Thanks for the link to the code examples page; I’ll take a look.
Hi Sam, I’ve tried the code method, but have never used code before so am rather clueless. The buttons are disabled, even when going in via the category page. Please see screenshot below and let me know what I’m doing wrong. Many thanks.
Hi again,
First off, kudos for attempting this if you’ve never used code before. This is a bit of a complex scenario for your first foray into code, but let’s see if we can get it working anyhow.
From the looks of it, I think you’ve done well with the code. I’m assuming you’ve also added the code that fills the local storage with the plant links on another page.
Looks to me like you are trying to connect the button using the Connect to Data panel. You don’t need to do that. The code (on lines 17-20 and 25-28) take care of enabling the buttons and setting their actions. Try disconnecting the buttons and see if that helps.
Hi Sam,
Thanks, I’ve disconnected the buttons from the Connect to Date panel, but they don’t work, so I assume it has something to do with this comment of yours:
I’m assuming you’ve also added the code that fills the local storage with the plant links on another page.
I don’t understand that, so I guess, haven’t done it! Please help further. Many thanks.
Take a look again at the post you copied the code from. There are two code snippets. The first one (the one you have not used yet) needs to be placed on you index-type page. Of course, you’ll have to edit the code so all the IDs match the ones on your page, etc.
Thanks, Sam. Ok, I’ve added that code to the index-type page and it seems to have accepted it.
Here’s the code:
But, when I preview and click onto a single item page where the buttons are, I get this error message:
Wix code SDK Warning: The src parameter that is passed to the src method cannot be set to null or undefined.
Thanks so much for keeping with me on this issue. If it starts to get too intricate, I’ll have to wait until another method presents itself.
Hi, I’ve added this code to the index type page
I’ve added this code to the item page code
The next button changes, and in preview mode, this is the message in the code console.
We just added a new article demonstrating how create previous and next buttons for a dynamic item page.
https://support.wix.com/en/article/how-to-create-previous-and-next-buttons-for-a-dynamic-item-page
We’d appreciate any feedback on whether or not the article helped you create previous and next buttons on your dynamic item pages.