Loading README.txt→README.md +15 −20 Original line number Diff line number Diff line CONTENTS OF THIS FILE --------------------- ## CONTENTS OF THIS FILE * Introduction * Requirements * Installation * Configuration * Developers * Troubleshooting * Sponsors * Maintainers INTRODUCTION ------------ ## INTRODUCTION This module let editors configure search terms per entity that should trigger elevate (best bets) or exclude when users is searching the site. Loading @@ -30,21 +29,21 @@ Notice: the module does, at the moment, not support generation of elevate.xml for Apache Solr. Or similar solutions for other search backends. It is fully search query based! REQUIREMENTS ------------ ## REQUIREMENTS * Search API (https://www.drupal.org/project/search_api) * Apache Solr integration: ** Search API Solr (https://www.drupal.org/project/search_api_solr) ** Apache Solr 4.7+ (older versions does not support elevateIds and exlcudeIds) INSTALLATION ------------ ## INSTALLATION * Install as you would normally install a contributed drupal module. See: https://www.drupal.org/documentation/install/modules-themes/modules-8 for further information. CONFIGURATION ------------- ## CONFIGURATION After installation add a field of the type "Search API Best Bets" to one or more entity bundles (e.g. content types) where you want best bets support. Loading @@ -61,8 +60,7 @@ on the elevated items send to the search back as part of the search query. The former is not always working as expected in Solr, and in such cases can the latter option be used. DEVELOPERS ---------- ## DEVELOPERS The Search API Best Bets modules provides the following ways for developers to extend the functionality: Loading @@ -78,15 +76,12 @@ extend the functionality: Other templates / theming - Get the elevate status from $item->getExtraData('elevated'). TROUBLESHOOTING --------------- - ## SPONSORS SPONSORS -------- * FFW - https://ffwagency.com MAINTAINERS ----------- ## MAINTAINERS Current maintainers: * Jens Beltofte (beltofte) - https://drupal.org/u/beltofte * Stephen Mustgrave (smustgrave) - https://drupal.org/u/smustgrave search_api_best_bets.info.yml +1 −2 Original line number Diff line number Diff line name: Search API Best Bets type: module description: Let editors define best bets / promoted search results per entity in Drupal. core: 8.x core_version_requirement: ^8 || ^9 core_version_requirement: ^9 || ^10 package: Search dependencies: - drupal:field Loading search_api_best_bets.install 0 → 100644 +47 −0 Original line number Diff line number Diff line <?php /** * @file * The search_api_best_bets install. */ use Drupal\field\Entity\FieldStorageConfig; /** * Update existing field of type search_api_best_bets, allow 360 characters. */ function search_api_best_bets_update_9301(&$sandbox) { $num_chars = 360; // Check for existing field of type search_api_best_bets. $ref_fields = \Drupal::service('entity_type.manager') ->getStorage('field_storage_config') ->loadByProperties(['type' => 'search_api_best_bets']); /** @var \Drupal\field\Entity\FieldStorageConfig $ref_field */ foreach ($ref_fields as $ref_field) { $field_name = $ref_field->getName(); // Resize the columns. $database = \Drupal::database(); $database->query("ALTER TABLE node__{$field_name} MODIFY {$field_name}_query_text VARCHAR($num_chars)"); $database->query("ALTER TABLE node_revision__{$field_name} MODIFY {$field_name}_query_text VARCHAR($num_chars)"); // Update storage schema. $storage_key = "node.field_schema_data." . $field_name; $storage_schema = \Drupal::keyValue('entity.storage_schema.sql'); $field_schema = $storage_schema->get($storage_key); $field_schema["node__{$field_name}"]['fields']["{$field_name}_query_text"]['length'] = $num_chars; $field_schema["node_revision__{$field_name}"]['fields']["{$field_name}_query_text"]['length'] = $num_chars; $storage_schema->set($storage_key, $field_schema); // Update field configuration. $config = \Drupal::configFactory() ->getEditable("field.storage.node.{$field_name}"); $config->set('settings.max_length', $num_chars); $config->save(TRUE); // Update field storage configuration. FieldStorageConfig::loadByName('node', $field_name)->save(); } } search_api_best_bets.module +0 −1 Original line number Diff line number Diff line Loading @@ -8,7 +8,6 @@ use Drupal\Core\Access\AccessResult; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Session\AccountInterface; /** Loading src/Plugin/Field/FieldType/SearchApiBestBetsFieldItem.php +1 −1 Original line number Diff line number Diff line Loading @@ -27,7 +27,7 @@ class SearchApiBestBetsFieldItem extends FieldItemBase { 'columns' => [ 'query_text' => [ 'type' => 'varchar', 'length' => 64, 'length' => 360, ], 'exclude' => [ 'type' => 'int', Loading Loading
README.txt→README.md +15 −20 Original line number Diff line number Diff line CONTENTS OF THIS FILE --------------------- ## CONTENTS OF THIS FILE * Introduction * Requirements * Installation * Configuration * Developers * Troubleshooting * Sponsors * Maintainers INTRODUCTION ------------ ## INTRODUCTION This module let editors configure search terms per entity that should trigger elevate (best bets) or exclude when users is searching the site. Loading @@ -30,21 +29,21 @@ Notice: the module does, at the moment, not support generation of elevate.xml for Apache Solr. Or similar solutions for other search backends. It is fully search query based! REQUIREMENTS ------------ ## REQUIREMENTS * Search API (https://www.drupal.org/project/search_api) * Apache Solr integration: ** Search API Solr (https://www.drupal.org/project/search_api_solr) ** Apache Solr 4.7+ (older versions does not support elevateIds and exlcudeIds) INSTALLATION ------------ ## INSTALLATION * Install as you would normally install a contributed drupal module. See: https://www.drupal.org/documentation/install/modules-themes/modules-8 for further information. CONFIGURATION ------------- ## CONFIGURATION After installation add a field of the type "Search API Best Bets" to one or more entity bundles (e.g. content types) where you want best bets support. Loading @@ -61,8 +60,7 @@ on the elevated items send to the search back as part of the search query. The former is not always working as expected in Solr, and in such cases can the latter option be used. DEVELOPERS ---------- ## DEVELOPERS The Search API Best Bets modules provides the following ways for developers to extend the functionality: Loading @@ -78,15 +76,12 @@ extend the functionality: Other templates / theming - Get the elevate status from $item->getExtraData('elevated'). TROUBLESHOOTING --------------- - ## SPONSORS SPONSORS -------- * FFW - https://ffwagency.com MAINTAINERS ----------- ## MAINTAINERS Current maintainers: * Jens Beltofte (beltofte) - https://drupal.org/u/beltofte * Stephen Mustgrave (smustgrave) - https://drupal.org/u/smustgrave
search_api_best_bets.info.yml +1 −2 Original line number Diff line number Diff line name: Search API Best Bets type: module description: Let editors define best bets / promoted search results per entity in Drupal. core: 8.x core_version_requirement: ^8 || ^9 core_version_requirement: ^9 || ^10 package: Search dependencies: - drupal:field Loading
search_api_best_bets.install 0 → 100644 +47 −0 Original line number Diff line number Diff line <?php /** * @file * The search_api_best_bets install. */ use Drupal\field\Entity\FieldStorageConfig; /** * Update existing field of type search_api_best_bets, allow 360 characters. */ function search_api_best_bets_update_9301(&$sandbox) { $num_chars = 360; // Check for existing field of type search_api_best_bets. $ref_fields = \Drupal::service('entity_type.manager') ->getStorage('field_storage_config') ->loadByProperties(['type' => 'search_api_best_bets']); /** @var \Drupal\field\Entity\FieldStorageConfig $ref_field */ foreach ($ref_fields as $ref_field) { $field_name = $ref_field->getName(); // Resize the columns. $database = \Drupal::database(); $database->query("ALTER TABLE node__{$field_name} MODIFY {$field_name}_query_text VARCHAR($num_chars)"); $database->query("ALTER TABLE node_revision__{$field_name} MODIFY {$field_name}_query_text VARCHAR($num_chars)"); // Update storage schema. $storage_key = "node.field_schema_data." . $field_name; $storage_schema = \Drupal::keyValue('entity.storage_schema.sql'); $field_schema = $storage_schema->get($storage_key); $field_schema["node__{$field_name}"]['fields']["{$field_name}_query_text"]['length'] = $num_chars; $field_schema["node_revision__{$field_name}"]['fields']["{$field_name}_query_text"]['length'] = $num_chars; $storage_schema->set($storage_key, $field_schema); // Update field configuration. $config = \Drupal::configFactory() ->getEditable("field.storage.node.{$field_name}"); $config->set('settings.max_length', $num_chars); $config->save(TRUE); // Update field storage configuration. FieldStorageConfig::loadByName('node', $field_name)->save(); } }
search_api_best_bets.module +0 −1 Original line number Diff line number Diff line Loading @@ -8,7 +8,6 @@ use Drupal\Core\Access\AccessResult; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Session\AccountInterface; /** Loading
src/Plugin/Field/FieldType/SearchApiBestBetsFieldItem.php +1 −1 Original line number Diff line number Diff line Loading @@ -27,7 +27,7 @@ class SearchApiBestBetsFieldItem extends FieldItemBase { 'columns' => [ 'query_text' => [ 'type' => 'varchar', 'length' => 64, 'length' => 360, ], 'exclude' => [ 'type' => 'int', Loading