added thesaurus ordered in sapi solr database index
This commit is contained in:
@@ -67,3 +67,46 @@ function materio_sapi_preprocess_fieldset(&$variables) {
|
||||
$variables['legend']['attributes'] = new Attribute($variables['element']['#legend_attributes']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ? https://happyculture.coop/blog/drupal-8-declarer-un-champ-extrafield-calcule-computed-field
|
||||
/**
|
||||
* Implements hook_entity_bundle_field_info().
|
||||
*/
|
||||
function materio_sapi_entity_bundle_field_info(\Drupal\Core\Entity\EntityTypeInterface $entity_type, $bundle, array $base_field_definitions) {
|
||||
$fields = [];
|
||||
if ($entity_type->id() == 'node') {
|
||||
if ($bundle == 'materiau') {
|
||||
for ($i=0; $i < 5 ; $i++) {
|
||||
$fields["thesaurus_$i"] = \Drupal\Core\Field\BaseFieldDefinition::create('entity_reference')
|
||||
->setLabel(t("Thesaurus $i"))
|
||||
->setComputed(TRUE)
|
||||
->setSetting('target_type', 'taxonomy_term')
|
||||
->setSetting('handler_settings',['target_bundles'=>['thesaurus'=>'thesaurus']] )
|
||||
->setClass('\Drupal\materio_sapi\ThesaurusRefComputed')
|
||||
->setDisplayConfigurable('view', FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $fields;
|
||||
}
|
||||
|
||||
|
||||
// ? https://www.webomelette.com/creating-pseudo-fields-drupal-8
|
||||
// /**
|
||||
// * Implements hook_entity_extra_field_info().
|
||||
// */
|
||||
// function materio_sapi_entity_extra_field_info() {
|
||||
// $extra = array();
|
||||
|
||||
// foreach (NodeType::loadMultiple() as $bundle) {
|
||||
// $extra['node'][$bundle->Id()]['display']['my_own_pseudo_field'] = array(
|
||||
// 'label' => t('My own field'),
|
||||
// 'description' => t('This is my own pseudo-field'),
|
||||
// 'weight' => 100,
|
||||
// 'visible' => false,
|
||||
// );
|
||||
// }
|
||||
|
||||
// return $extra;
|
||||
// }
|
Reference in New Issue
Block a user