Override the existing block display plugin

Created on 9 January 2024, over 1 year ago
Updated 6 August 2025, 12 days ago

Problem/Motivation

Instead of adding a new type of display block, we could change the class of existing block displays with the new class. This way when you have an existing views block and add a contextual filter, you can allow this filter to be overridden. Now you would need to create a new block, configure it the same and add the contextual settings.

Proposed resolution

Remove the annotation from ViewsBlockOverride and use alter hook to change out the block display class.

function views_block_override_views_plugins_display_alter(array &$plugins) {
$plugins['block']['class'] = 'Drupal\\views_block_override\\Plugin\\views\display\ViewsBlockOverride';
}

Remaining tasks

- write the hook
- remove the annotation from the ViewsBlockOverride class (maybe relocate it ??)
- create an updb hook to change existing block override displays and reset the "views_block_override" id to "block".

User interface changes

none

API changes

none

Data model changes

"views_block_override" plugin id will become "block"

Feature request
Status

Active

Version

1.2

Component

Code

Created by

🇧🇪Belgium kriboogh

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

Merge Requests

Comments & Activities

  • Issue created by @kriboogh
  • First commit to issue fork.
  • Pipeline finished with Success
    12 days ago
    Total: 135s
    #566021
  • 🇧🇪Belgium kriboogh

    I added the possibility to use core block display's without the need to create a special "Blocks with overrides" display. This allows for easier modification of existing views.

    Also refactored the way overrides are exposed to the view. They are now plugins and can be easily overwritten or added by providing /plugin/views/display/block/override plugins.

    The existing "Blocks with overrides" display plugin is still there and should keep working, but use should then be discouraged.

  • Pipeline finished with Success
    12 days ago
    Total: 164s
    #566031
  • Pipeline finished with Running
    12 days ago
    #566130
Production build 0.71.5 2024