app/helpers/blacklight_helper.rb in curate-0.5.4 vs app/helpers/blacklight_helper.rb in curate-0.5.5

- old
+ new

@@ -14,6 +14,18 @@ include Blacklight::BlacklightHelperBehavior def application_name t('sufia.product_name') end -end \ No newline at end of file + + # Loads the object and returns its name(for creator)/title(for collection) + def get_value_from_pid(field, value) + attr_value = "" + begin + attr_value = ActiveFedora::Base.load_instance_from_solr(value.split("/").last).name if field == "desc_metadata__creator_sim" + attr_value = ActiveFedora::Base.load_instance_from_solr(value).title if field == "collection_sim" + rescue => e + logger.warn("WARN: Helper method get_value_from_pid raised an error when loading #{value}. Error was #{e}") + end + return attr_value.blank? ? value : attr_value + end +end