'cool!', '#weight' => 20]; $vars['attributes']['class'][] = 'custom'; } /** * Alter the region options in the field UI screen. * * This function is only called when a layout has been chosen. * * @param array $context * A collection of keys for the context. The keys are 'entity_type', * 'bundle' and 'view_mode'. * @param array $region_info * A collection of info for regions. The keys are 'region_options' * and 'table_regions'. */ function hook_ds_layout_region_alter(array $context, array &$region_info) { $region_info['region_options']['my_region'] = 'New region'; $region_info['table_regions']['my_region'] = [ 'title' => Html::escape('New region'), 'message' => t('No fields are displayed in this region'), ]; } /** * Alter the field label options. * * Note that you will either update the preprocess functions or the * field.html.twig file when adding new options. * * @param array $field_label_options * A collection of field label options. */ function hook_ds_label_options_alter(array &$field_label_options) { $field_label_options['label_after'] = t('Label after field'); } /** * Alter the view mode just before it's rendered by the DS views entity plugin. * * @param string $view_mode * The name of the view mode. * @param array $context * A collection of items which can be used to identify in what * context an entity is being rendered. The variable contains 3 keys: * - entity: The entity being rendered. * - view_name: the name of the view. * - display: the name of the display of the view. */ function hook_ds_views_view_mode_alter(&$view_mode, array $context) { if ($context['view_name'] == 'my_view_name') { $view_mode = 'new_view_mode'; } } /** * Theme an entity through an advanced function. * * The function is coming from the views entity plugin. * * @param \Drupal\Core\Entity\EntityInterface $entity * The entity. * @param string $view_mode * The name of the view mode. * * @return array * The rendered entity */ function hook_ds_views_row_render_entity(EntityInterface $entity, $view_mode) { $entity = Node::load(1); return \Drupal::service('entity_type.manager')->getViewBuilder('node')->view($entity, $view_mode); } /** * Theme an entity through an advanced function. * * Function is coming from the views entity plugin. * * @param array $build * The builded entity. * @param array $context * Collection of parameters (row, view and view_mode). */ function hook_ds_views_row_render_entity_alter(array &$build, array $context) { // You can do whatever you want to here. $build['data'] = [ '#markup' => 'Sample text', '#weight' => 20, ]; } /** * Allow modules to provide additional classes for regions and layouts. */ function hook_ds_classes_alter(&$classes, $name) { if ('ds_classes_regions' === $name) { $classes['css-class-name'] = t('Custom Styling'); } } /** * Allow modules to alter the operations on the dynamic field overview page. */ function hook_ds_field_operations_alter(&$operations, $field) { if ($field['type'] == 'block') { unset($operations['edit']); } } /** * Allow modules to alter the onclick url. * * @param Url $url */ function hook_ds_onclick_url_alter(Url $url) { $query = [ 'filter' => 'test' ]; $url->setOption('query', $query); } /** * @} End of "addtogroup hooks". */