Add support for splitsing a text block in 2 or 3 columns

Created on 9 June 2023, about 1 year ago

Problem/Motivation

Right now there's an option to add a text block to the different sections, but it would be nice that in the rocketship 1 column layout, when adding a text block, you can select to splits it over 1, 2 or 3 columns.

That way it can be automatically divided over the different columns with css.

Proposed resolution

  • Add a select list to the text layout with the options (later on this can maybe be changed by images)
  • Implement theming for the options
  • Hide this option in all layouts available except the rocketship 1 column layout

possible issues

This change will be applicable on all existing projects, so css needs to be done on a rocketship level + communication through release notes is necessary

✨ Feature request
Status

Active

Version

6.0

Component

Code

Created by

πŸ‡§πŸ‡ͺBelgium brentg Ghent

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • 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
  • πŸ‡§πŸ‡ͺBelgium brentg Ghent
Production build 0.69.0 2024