diff --git a/app/controllers/catalog_controller.rb b/app/controllers/catalog_controller.rb index f2c2e9b..21b6199 100644 --- a/app/controllers/catalog_controller.rb +++ b/app/controllers/catalog_controller.rb @@ -91,6 +91,8 @@ class CatalogController < ApplicationController config.add_index_field 'title_vern_display', label: 'Title' config.add_index_field 'author_display', label: 'Author' config.add_index_field 'author_vern_display', label: 'Author' + config.add_index_field 'combine_author_field_whatever_we_want', label: 'Accessor Author', accessor: :display_combined_author + config.add_index_field 'linked_author_field', label: 'Helper Author', helper_method: :helper_method_demo, field: :author_display config.add_index_field 'format', label: 'Format' config.add_index_field 'language_facet', label: 'Language' config.add_index_field 'published_display', label: 'Published' diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index a2f4870..e7fd247 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,3 +1,5 @@ module ApplicationHelper - + def helper_method_demo(document:,field:,value:,config:) + "#{document.first(:author_vern_display)} (#{link_to document.first(:author_display), search_action_url(q: document.first(:author_display), search_field: :author)})".html_safe + end end diff --git a/app/models/solr_document.rb b/app/models/solr_document.rb index 9b896f4..1668eaf 100644 --- a/app/models/solr_document.rb +++ b/app/models/solr_document.rb @@ -16,4 +16,8 @@ class SolrDocument # and Blacklight::Document::SemanticFields#to_semantic_values # Recommendation: Use field names from Dublin Core use_extension(Blacklight::Document::DublinCore) + + def display_combined_author + "#{first(:author_vern_display)} (#{first(:author_display)})" + end end