diff --git a/config/install/core.entity_view_display.node.publication.default.yml b/config/install/core.entity_view_display.node.publication.default.yml index 43d8977..4ee1079 100644 --- a/config/install/core.entity_view_display.node.publication.default.yml +++ b/config/install/core.entity_view_display.node.publication.default.yml @@ -22,12 +22,14 @@ dependencies: - field.field.node.publication.field_show_table_of_content - field.field.node.publication.field_tags - field.field.node.publication.field_topic + - field.field.node.publication.field_content_category - node.type.publication module: - datetime - entity_reference_revisions - options - user + - term_reference_tree id: node.publication.default targetEntityType: node bundle: publication @@ -209,6 +211,17 @@ content: third_party_settings: { } type: entity_reference_label region: content + field_content_category: + type: term_reference_tree + weight: 5 + region: content + settings: + start_minimized: true + leaves_only: true + select_parents: false + cascading_selection: 0 + max_depth: 0 + third_party_settings: { } links: weight: 100 region: content diff --git a/config/install/field.field.node.publication.field_content_category.yml b/config/install/field.field.node.publication.field_content_category.yml new file mode 100644 index 0000000..f10cc1d --- /dev/null +++ b/config/install/field.field.node.publication.field_content_category.yml @@ -0,0 +1,28 @@ +langcode: en +status: true +dependencies: + config: + - field.storage.node.field_content_category + - node.type.publication + - taxonomy.vocabulary.content_category +id: node.publication.field_content_category +field_name: field_content_category +entity_type: node +bundle: publication +label: 'Content category' +description: 'Select the most relevant option from the list of content categories. This mandatory field will help with search and filtering on the website.' +required: true +translatable: true +default_value: { } +default_value_callback: '' +settings: + handler: 'default:taxonomy_term' + handler_settings: + target_bundles: + content_category: content_category + sort: + field: name + direction: asc + auto_create: false + auto_create_bundle: '' +field_type: entity_reference diff --git a/tide_publication.install b/tide_publication.install index 6e77e5d..05755da 100644 --- a/tide_publication.install +++ b/tide_publication.install @@ -48,6 +48,15 @@ function tide_publication_update_10001() { $config->save(); } +/** + * Implements hook_update_dependencies(). + */ +function tide_publication_update_dependencies() { + $dependencies = []; + $dependencies['tide_publication'][10003] = ['tide_core' => 10005]; + return $dependencies; +} + /** * Update field_publication_authors cardinality and vocabulary to organisation. */ @@ -90,3 +99,20 @@ function tide_publication_update_10002() { $new_field->save(); } } + +/** + * Imports publication.field_content_category for existing sites. + */ +function tide_publication_update_10003() { + \Drupal::moduleHandler()->loadInclude('tide_core', 'inc', 'includes/helpers'); + $config_location = [\Drupal::service('extension.list.module')->getPath('tide_publication') . '/config/install']; + $config_read = _tide_read_config('field.field.node.publication.field_content_category', $config_location, TRUE); + $storage = \Drupal::entityTypeManager()->getStorage('field_config'); + $id = $storage->getIDFromConfigName('field.field.node.publication.field_content_category', $storage->getEntityType()->getConfigPrefix()); + if ($storage->load($id) == NULL) { + $config_entity = $storage->createFromStorageRecord($config_read); + $config_entity->save(); + } + \Drupal::moduleHandler()->loadInclude('tide_core', 'inc', 'includes/updates'); + _tide_core_content_category_form_display('publication'); +}