Skip to content

Blacklight pagination for prev next document doesn't work as lacks a search_session? #94

@stevenvandervalk

Description

@stevenvandervalk

https://github.com/vecnet/dl-discovery/blob/qa-deploy/app/views/catalog/show.html.erb

Should render a partial previous_and_next_doc for pagination to previous next and back to search. It seems to not work currently as

<% if @previous_document || @next_document %>

don't exist until the Blacklight lib search_context.rb makes them as it contains the function setup_next_and_previous_documents

 # calls setup_previous_document then setup_next_document.
  # used in the show action for single view pagination.
  def setup_next_and_previous_documents
    if search_session['counter'] and current_search_session
      index = search_session['counter'].to_i - 1
      response, documents = get_previous_and_next_documents_for_search index, current_search_session.query_params.with_indifferent_access

      search_session['total'] = response.total
      @search_context_response = response
      @previous_document = documents.first
      @next_document = documents.last
    end
  rescue Blacklight::Exceptions::InvalidRequest => e
    logger.warn "Unable to setup next and previous documents: #{e}"
  end

That code should already be running as part of the show method in catalog.rb

 # get a single document from the index
    # to add responses for formats other than html or json see _Blacklight::Document::Export_
    def show
      @response, @document = fetch params[:id]

      respond_to do |format|
        format.html { setup_next_and_previous_documents }

Just in case I included it in the controller manually but no dice, still no @previous_document etc.

@dbrower Any ideas?

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions