Prev/Next on item page doesn't work when item pg called directly

Hi. I followed the instructions in this article to create previous/next buttons in an item dynamic page:

Works beautifully as long as the item page is opened from a category dynamic page or an index page of some kind that has the dataset in it. But if the user clicks a link somewhere on a “normal” page and the item page is opened directly for that item, the prev/next is all mixed up, because it didn’t have the opportunity to assemble the scroll list that the article describes.

Can anyone please help me understand how to get around this problem?

Thank you.

Hi! You should add index page code for each page with link to dynamic page to avoid such a problem or add index page code to Site tab and set Show on All pages for myDataset .

OK, thanks. So I also need a dataset on all the relevant pages, too? Will using the same name for the dataset be enough to allow it to work?

Yes, a dataset on all the relevant pages should be added with name as defined in code for this page - i mean if you change dataset name - you should change name in code for this page respectively or use show an page option