Previous / Next item buttons only within the item-set

Hi,
I am using Omekas and the Next module. I use the buttons Previous item / Next item. Everything works. However, I need a modification. I would like these buttons to work only within the Item-set the item comes from. For example.

  1. I clicked item-set (collection): Books.
  2. I clicked on the first item in this collection.
  3. I click Next item and another item appears, but according to the date it was added. This item is not from the collection: Books.
    Is it possible to limit the buttons only to the collection clicked in step 2?

Thanks

I have done this for a project in the past. My solution is a little cumbersome but it works. Basically, I added query params to all links that lead to an item record from a collection or item type view.

For example, if the user is viewing items with the item type Text (id 1) and the collection with an id of 2, the url is modified like items/show/1?type=1&collection=2. Then I read those parameters using html_escape($_GET['collection']) and html_escape($_GET['type']) on the items/show page to create a scoped navigation.

See link below…

The easiest way to add those query params is via JavaScript, e.g.

addEventListener('DOMContentLoaded', event => {
    let params = new URLSearchParams(window.location.search);
    // if user is browsing by type or collection, add value as param to each item link
    if(params.get("collection") || params.get("type") || window.location.pathname.includes('collections/show')){
    var itemlinks = document.querySelectorAll('.item a'); // you might need to change this selector
    itemlinks.forEach(link=>{
        if(link.pathname.includes('items/show')){
            link.href += (params.get("collection") ? '?collection='+params.get("collection") : '');
            link.href += (params.get("type") ? (link.href.includes('?') ? '&' : '?')+'type='+params.get("type") : '');
            link.href += (window.location.pathname.includes('collections/show') ? '?collection='+window.location.pathname.substring(window.location.pathname.lastIndexOf('/') + 1): '')
        }
    })      
})

I just realized that this is in the Omeka S forum. The solution is for Omeka Classic, so you’ll need to modify accordingly, but the basic idea should still work.

Unfortunately, I can’t deal with this problem :frowning: