- Issue created by @brentg
- π§πͺBelgium brentg Ghent
The access can be handled in a block_type_form_alter
e.g. a variation of the following (this was only to exclude it from the 2 column layout)
function MODULE_block_type_form_alter(array &$form, FormStateInterface &$form_state, string $block_type) { switch ($block_type) { case 'cb_text': $current_section = $form_state->getFormObject()->getCurrentSection(); if ($current_section->getLayoutId() === 'rs_two_col') { $form['field_columns']['#access'] = FALSE; } break; } }
And the class can be added as following
function MODULE_block_content_view_alter(array &$build, BlockContentInterface $entity, EntityViewDisplayInterface $display) { if ($entity->hasField('field_columns')) { $columns = $entity->get('field_columns')->value ?? 'one-column'; $build['#attributes']['class'][] = 'block--' . $columns; } }
- Status changed to Active
about 1 year ago 9:51am 9 June 2023