Skip to content

Configuration Results View

Chris Beer edited this page Feb 1, 2014 · 20 revisions

The Blacklight results views can

Index View

Index View

Basic configuration

The index view is configured from your CatalogController's blacklight configuration. Here is a listing of the configuration parameters Blacklight uses and their default values:

configure_blacklight do |config|
   ...

   config.index.title_field = unique_key
   config.index.partials = [:index_header, :thumbnail, :index]
   config.index.display_type_field = 'format'
   config.index.group = false

   ...
end

The configuration keys are not limited or restricted, so plugins or applications that need additional index configuration may add additional parameters directly.

config.index.my_custom_parameters = "some value"

title_field

The title field setting determines the Solr field that Blacklight will use to display the record title.

If you need additional customization (e.g. to concatenate two fields, etc), you can provide your own implementation of the #document_heading partial method, e.g.

module ApplicationHelper
  def document_heading document = nil
    document ||= @document
    document.first(:main_title) + " - " + document.first(:sub_title)
  end
end

Partials and display_type_field

You can configure the partials that Blacklight will assemble to display a search result.

By default, Blacklight will render these three basic partials when displaying a document. The partial names are a combination of two configuration settings. The base name of the partial is given by the partials setting. The suffix is based on the type of document given by the value of the display_type_field. If a partial is not found with the given display_type_field value, it will attempt to render a default version of the base partial. If no matching partial is found, nothing will be displayed for that document.

For example, using the default values and a document without a format field, these partials will be rendered:

  • index_header_default.html.erb: The document title and document actions
  • thumbnail_default.html.erb: A representative thumbnail (from the thumbnail_field configuration below)
  • index_default.html.erb: A list of document fields

However, if the document had a format field with the value book, Blacklight would attempt to render these partials:

  • index_header_book.html.erb; if that doesn't exist, it will fall back to index_header_default.html.erb
  • thumbnail_book.html.erb; fall back to thumbnail_default.html.erb
  • index_book.html.erb; fall back to index_default.html.erb

Blacklight only provides default partials for these three base partials. If you were to provide an app/views/catalog/_index_book.html.erb partial, Blacklight would render that partial instead of the default.

(Advanced) Result Collapsing / Grouping

Blacklight can use Solr's result collapsing feature. To use this feature, set the group parameter to the name of the field that Blacklight should use to render collapsed result sets.

Fields

Labels

Solr Fields

Model Accessors

Highlight

Helper Method

Link To Search

Schema.org configuration

View Types

Blacklight provides a default "list" view of results.

(Advanced) Results Grouping

Show view

Show view

Basic configuration

Clone this wiki locally