Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
This a Drupal 7 version of the patch listed in #1000360: Contextual disabling of core block rendering. It is a great feature and it would be nice to see it in the release version.
It provides a select box in the Reactions -> Blocks area to enable/disable core blocks. When set to disabled, any regions configured within the current context are only populated with blocks from the context.
This is my first patch, so it's probably not perfect and I'm not certain I handled things the best way. Tips or suggestions are welcome.
Comment | File | Size | Author |
---|---|---|---|
context_disable_core_blocks_v7.patch | 2.16 KB | cameron prince | |
Comments
Comment #1
guillaumev CreditAttribution: guillaumev commentedThis is working well and would love to see this integrated in context as well. One small improvement to be done though: I was hoping to use this in order to have the main content block disabled in the content region, however for this specific block (the main content block) for some reason it doesn't work. With all other blocks it works just fine...
Comment #2
hefox CreditAttribution: hefox commentedMore than one review is likely be warrented
Comment #3
ns_j CreditAttribution: ns_j commentedSeems to have solved the problem for me. Thanks!
Comment #4
hefox CreditAttribution: hefox commentedWhite space
This could likely be simplified to !empty($options['disable_core_blocks']).
Not sure if a select vs a simple checkbox is better here.
The regions the blocks are in are the regions disabled for that context? Seems a bit confusing; would it be possible/better to have a reaction that disabled core blocks in regions (with region selection)?
Two level deep ternary, but only two possible outcomes ($blocks or array_merge); likely can be switched over to one level, which would be easier to read.
isset($page[$region]) && !isset($core_disabled..) ? arraY_merge : $blocks
Comment #5
jrabeemer CreditAttribution: jrabeemer commentedThis patch is much needed. Disabling block rendering while not disabling Blocks UI (because other modules place their UI inside Blocks UI) is very useful and makes Context a complete blocks replacement.
In my use case, I want to remove messages block and "Main page content" from rendering, no default blocks rendered and totally rely on Context for all block placement.
+1 to #4 suggestions for code clean up.
Also provide a "Main page content" must be present and in a visible region warning. Otherwise you could end up with an empty admin page with no way to fix it unless you use Drush to re-enable Block module.
Comment #6
Orkut Murat YılmazIMHO, this patch must be included in next update.
Comment #7
Ömer Atakoğlu CreditAttribution: Ömer Atakoğlu commentedPlease add this patch to the next update.
Comment #8
PCateNumbersUSA CreditAttribution: PCateNumbersUSA commentedIs there an updated patch for beta4? Any word on whether this functionality will be included in the next release?
Comment #9
mzwyssig CreditAttribution: mzwyssig commentedI would be very interested for this feature to be released in the next version as well.
Comment #10
jessia CreditAttribution: jessia commentedDid anything ever happen with this patch? I've been looking for something like this!
Comment #11
ianthomas_ukWith the patch as it stands Drupal will still go to all the work of rendering the block, even though it's not displayed. Depending on the block in question that could add significant work/delay to the page load. Can we not stop these blocks from being rendered in the first place?