diff --git a/includes/config.inc b/includes/config.inc index fa0f3b0..c4e4731 100644 --- a/includes/config.inc +++ b/includes/config.inc @@ -523,6 +523,14 @@ function islandora_solr_metadata_config_field_form($form, &$form_state, $config_ '#default_value' => $get_default('uri_replacement', ''), '#autocomplete_path' => 'islandora_solr/autocomplete_luke', ); + if (islandora_solr_is_date_field($field_name)) { + $set['date_format'] = array( + '#type' => 'textfield', + '#title' => t('Date format'), + '#default_value' => $get_default('date_format', ''), + '#description' => t('The format of the date, as it will be displayed in the search results. Use PHP date() formatting. Works best when the date format matches the granularity of the source data. Otherwise it is possible that there will be duplicates displayed.', array('!url' => 'http://php.net/manual/function.date.php')), + ); + } // Add in truncation fields for metadata field. $truncation_config = array( 'default_values' => array( diff --git a/theme/theme.inc b/theme/theme.inc index a5367eb..1666344 100644 --- a/theme/theme.inc +++ b/theme/theme.inc @@ -225,6 +225,7 @@ function islandora_solr_metadata_query_fields($object, &$solr_fields) { 'hyperlink' => 0, 'formatter' => NULL, 'uri_replacement' => '', + 'date_format' => '', ); // Replace URI or PID with a configured field. if (!empty($field_config['uri_replacement'])) { @@ -263,7 +264,9 @@ function islandora_solr_metadata_query_fields($object, &$solr_fields) { )); } } - + if (islandora_solr_is_date_field($solr_field) && !empty($solr_fields[$solr_field]['date_format'])) { + $value = format_date(strtotime($value), 'custom', $solr_fields[$solr_field]['date_format'], 'UTC'); + } if (is_callable($field_config['formatter'])) { $value = call_user_func($field_config['formatter'], $value); }