diff --git a/config/optional/core.entity_form_display.node.tide_search_listing.default.yml b/config/optional/core.entity_form_display.node.tide_search_listing.default.yml index 0f71275..33a7184 100644 --- a/config/optional/core.entity_form_display.node.tide_search_listing.default.yml +++ b/config/optional/core.entity_form_display.node.tide_search_listing.default.yml @@ -2,6 +2,7 @@ langcode: en status: true dependencies: config: + - field.field.node.tide_search_listing.field_above_results_content - field.field.node.tide_search_listing.field_below_results_content - field.field.node.tide_search_listing.field_custom_sort_configuration - field.field.node.tide_search_listing.field_featured_image @@ -148,6 +149,14 @@ content: region: content settings: { } third_party_settings: { } + field_above_results_content: + type: text_textarea + weight: 7 + region: content + settings: + rows: 5 + placeholder: '' + third_party_settings: { } field_below_results_content: type: text_textarea weight: 8 diff --git a/config/optional/core.entity_view_display.node.tide_search_listing.default.yml b/config/optional/core.entity_view_display.node.tide_search_listing.default.yml index 42bf5b0..ce221cd 100644 --- a/config/optional/core.entity_view_display.node.tide_search_listing.default.yml +++ b/config/optional/core.entity_view_display.node.tide_search_listing.default.yml @@ -2,6 +2,7 @@ langcode: en status: true dependencies: config: + - field.field.node.tide_search_listing.field_above_results_content - field.field.node.tide_search_listing.field_below_results_content - field.field.node.tide_search_listing.field_custom_sort_configuration - field.field.node.tide_search_listing.field_featured_image @@ -43,6 +44,13 @@ content: third_party_settings: { } weight: -20 region: content + field_above_results_content: + type: text_default + label: above + settings: { } + third_party_settings: { } + weight: 16 + region: content field_below_results_content: type: text_default label: above diff --git a/config/optional/core.entity_view_display.node.tide_search_listing.teaser.yml b/config/optional/core.entity_view_display.node.tide_search_listing.teaser.yml index d75e399..f8b7298 100644 --- a/config/optional/core.entity_view_display.node.tide_search_listing.teaser.yml +++ b/config/optional/core.entity_view_display.node.tide_search_listing.teaser.yml @@ -3,6 +3,7 @@ status: true dependencies: config: - core.entity_view_mode.node.teaser + - field.field.node.tide_search_listing.field_above_results_content - field.field.node.tide_search_listing.field_below_results_content - field.field.node.tide_search_listing.field_custom_sort_configuration - field.field.node.tide_search_listing.field_featured_image @@ -46,6 +47,7 @@ content: weight: 100 region: content hidden: + field_above_results_content: true field_below_results_content: true field_custom_sort_configuration: true field_featured_image: true diff --git a/config/optional/field.field.node.tide_search_listing.field_above_results_content.yml b/config/optional/field.field.node.tide_search_listing.field_above_results_content.yml new file mode 100644 index 0000000..fac13ef --- /dev/null +++ b/config/optional/field.field.node.tide_search_listing.field_above_results_content.yml @@ -0,0 +1,24 @@ +langcode: en +status: true +dependencies: + config: + - field.storage.node.field_above_results_content + - node.type.tide_search_listing + module: + - allowed_formats + - text +third_party_settings: + allowed_formats: + allowed_formats: { } +id: node.tide_search_listing.field_above_results_content +field_name: field_above_results_content +entity_type: node +bundle: tide_search_listing +label: 'Above results content' +description: '' +required: false +translatable: false +default_value: { } +default_value_callback: '' +settings: { } +field_type: text_long diff --git a/config/optional/field.storage.node.field_above_results_content.yml b/config/optional/field.storage.node.field_above_results_content.yml new file mode 100644 index 0000000..a49d810 --- /dev/null +++ b/config/optional/field.storage.node.field_above_results_content.yml @@ -0,0 +1,22 @@ +langcode: en +status: true +dependencies: + module: + - field_permissions + - node + - text +third_party_settings: + field_permissions: + permission_type: public +id: node.field_above_results_content +field_name: field_above_results_content +entity_type: node +type: text_long +settings: { } +module: text +locked: false +cardinality: 1 +translatable: true +indexes: { } +persist_with_no_fields: false +custom_storage: false diff --git a/tide_search.install b/tide_search.install index b8a9c53..906dada 100644 --- a/tide_search.install +++ b/tide_search.install @@ -56,3 +56,37 @@ function tide_search_update_10002() { $config->save(); } } + +/** + * Adds field_above_results_content field to search listing. + */ +function tide_search_update_10003() { + module_load_include('inc', 'tide_core', 'includes/helpers'); + $config_location = [\Drupal::service('extension.list.module')->getPath('tide_search') . '/config/optional']; + + $configs = [ + 'field.storage.node.field_above_results_content' => 'field_storage_config', + 'field.field.node.tide_search_listing.field_above_results_content' => 'field_config', + ]; + // Check if field already exported to config/sync. + foreach ($configs as $config => $type) { + $config_read = _tide_read_config($config, $config_location, TRUE); + $storage = \Drupal::entityTypeManager()->getStorage($type); + $config_entity = $storage->createFromStorageRecord($config_read); + $config_entity->save(); + } + + $form_configs = [ + 'core.entity_form_display.node.tide_search_listing.default', + 'core.entity_view_display.node.tide_search_listing.default', + 'core.entity_view_display.node.tide_search_listing.teaser', + ]; + foreach ($form_configs as $form_config) { + $config = \Drupal::configFactory()->getEditable($form_config); + $config_read = _tide_read_config($form_config, $config_location, FALSE); + $config->set('dependencies', $config_read['dependencies']); + $config->set('content', $config_read['content']); + $config->set('hidden', $config_read['hidden']); + $config->save(); + } +}