diff --git a/modules/schemadotorg_metatag/README.md b/modules/schemadotorg_metatag/README.md index 9fb0ded7c0e1c3deea2f3033ade37ccadfb69053..513a3622cc8983866e852ba6bdfa1c1caf362443 100644 --- a/modules/schemadotorg_metatag/README.md +++ b/modules/schemadotorg_metatag/README.md @@ -44,6 +44,7 @@ Configuration - Go to the Schema.org types configuration page. (/admin/config/schemadotorg/settings/types#edit-schemadotorg-metatag) - Go to the 'Metatag settings' details. +- Enter the Schema.org types that should have a meta tags field added when the Schema.org mapping is created. - Enter allowed meta tag groups to be displayed on node edit forms. - Go to the Schema.org properties configuration page. diff --git a/modules/schemadotorg_metatag/config/install/schemadotorg_metatag.settings.yml b/modules/schemadotorg_metatag/config/install/schemadotorg_metatag.settings.yml index 33b5897da8f0ead695dcc6c3ef7935db86a62674..8c77322d0582518b676e7677430841e4bf3ff58d 100644 --- a/modules/schemadotorg_metatag/config/install/schemadotorg_metatag.settings.yml +++ b/modules/schemadotorg_metatag/config/install/schemadotorg_metatag.settings.yml @@ -1,3 +1,5 @@ +schema_types: + - node--Thing default_groups: - basic - advanced diff --git a/modules/schemadotorg_metatag/config/schema/schemadotorg_metatag.settings.schema.yml b/modules/schemadotorg_metatag/config/schema/schemadotorg_metatag.settings.schema.yml index 26a0cc139019c3756d2f1a5e2fd9cea4f845d481..ff063c21518fbe10070734fea43c4de5f8171da7 100644 --- a/modules/schemadotorg_metatag/config/schema/schemadotorg_metatag.settings.schema.yml +++ b/modules/schemadotorg_metatag/config/schema/schemadotorg_metatag.settings.schema.yml @@ -2,6 +2,12 @@ schemadotorg_metatag.settings: type: config_object label: 'Schema.org Metatag settings' mapping: + schema_types: + type: sequence + label: 'Schema.org types' + sequence: + type: string + label: 'Schema.org types' default_groups: type: sequence label: 'Default groups' diff --git a/modules/schemadotorg_metatag/schemadotorg_metatag.install b/modules/schemadotorg_metatag/schemadotorg_metatag.install new file mode 100644 index 0000000000000000000000000000000000000000..ab452b75f035b9e41226da6f2c742f4d5008cde1 --- /dev/null +++ b/modules/schemadotorg_metatag/schemadotorg_metatag.install @@ -0,0 +1,18 @@ +<?php + +/** + * @file + * Installation hooks for the Schema.org Blueprints Metatag module. + */ + +declare(strict_types=1); + +/** + * Issue #3511774: Define Schema.org types that should have a meta tags field. + */ +function schemadotorg_metatag_update_10000(): void { + \Drupal::configFactory() + ->getEditable('schemadotorg_metatag.settings') + ->set('schema_types', ['node--Thing']) + ->save(); +} diff --git a/modules/schemadotorg_metatag/schemadotorg_metatag.module b/modules/schemadotorg_metatag/schemadotorg_metatag.module index ccc2d0bc85711fa28c0983b4e3ca3d30412392e0..3416263672ab987d170560f9d7bd1ef6e3174121 100644 --- a/modules/schemadotorg_metatag/schemadotorg_metatag.module +++ b/modules/schemadotorg_metatag/schemadotorg_metatag.module @@ -61,6 +61,16 @@ function schemadotorg_metatag_form_schemadotorg_types_settings_form_alter(array '#type' => 'details', '#title' => t('Metatag settings'), ]; + $form['schemadotorg_metatag']['schema_types'] = [ + '#type' => 'schemadotorg_settings', + '#title' => t('Schema.org type'), + '#description' => t('Enter the Schema.org types that should have a meta tags field added when the Schema.org mapping is created.'), + '#example' => ' +- entity_type_id--SchemaType +- entity_type_id--bundle +- entity_type_id--bundle--SchemaType +', + ]; $form['schemadotorg_metatag']['default_groups'] = [ '#type' => 'checkboxes', '#title' => t('Default meta tag groups'), diff --git a/modules/schemadotorg_metatag/src/SchemaDotOrgMetatagManager.php b/modules/schemadotorg_metatag/src/SchemaDotOrgMetatagManager.php index 196696911b72bb374f4389483d285d7a4eb5476b..b9ec5783ecb21ec8f950d5836a89dc2bb37cb128 100644 --- a/modules/schemadotorg_metatag/src/SchemaDotOrgMetatagManager.php +++ b/modules/schemadotorg_metatag/src/SchemaDotOrgMetatagManager.php @@ -60,8 +60,11 @@ class SchemaDotOrgMetatagManager implements SchemaDotOrgMetatagManagerInterface $bundle = $mapping->getTargetBundle(); $field_name = 'field_metatag'; - // Only add the meta tags field to node types. - if ($entity_type_id !== 'node') { + // Determine is the Schema.org mapping should have meta tag field. + $schema_types = $this->configFactory + ->get('schemadotorg_metatag.settings') + ->get('schema_types'); + if (!$this->schemaTypeManager->getSetting($schema_types, $mapping)) { return; }