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.
Awesome module. When configuring a block field it would be nice to specify a "Category" of blocks to make available. Right now you need to select each block within a Category to make available.
Comment | File | Size | Author |
---|---|---|---|
#33 | block-field-settings-selection-plugins-2876110-33.patch | 31.75 KB | michaellander |
| |||
#16 | block-field-2876110-16.patch | 7.22 KB | Bhanu951 |
| |||
#12 | block-field-2876110-12.patch | 7.58 KB | opi |
#7 | block-field-2876110-7.patch | 7.53 KB | arthur_lorenz |
| |||
#5 | block-field-2876110-5.patch | 7.5 KB | arthur_lorenz |
|
Comments
Comment #2
yobottehg CreditAttribution: yobottehg commentedFor me it seems like a good idea.
just check the following:
- custom block content entities
- views blocks
Perhaps we could look for the provider of the block.
Comment #3
scottsawyerI agree, this would be a great feature. This way, if a new block within a "category" is created, it could be immediately available.
Comment #4
dddbbb CreditAttribution: dddbbb as a volunteer commentedCame here to suggest something similar.
The issue is two fold in my experience:
1. Maintaining which blocks are available is a chore as blocks continue to be created. Having the option whitelist blocks by block provider rather than each individual block would really help in some uses cases.
2. The exported field instance config includes references to block content if you've chosen to whitelist those kinds of blocks. Config referencing/depending on content feels fragile and doesn't suit use cases where config is used to spin up anew site that might not have any content yet. Again, whitelisting by block provider would get around this.
Comment #5
arthur_lorenz CreditAttribution: arthur_lorenz at drunomics commentedAdded the possibility to filter available blocks by category.
Comment #6
fagoThanks, patch looks mostly good. Here a few minor remarks:
This should describe the keys and values of the array.
e.g., type-hint string[] and say:
A numerically indexed array of block categories.
missing space after foreach
Comment #7
arthur_lorenz CreditAttribution: arthur_lorenz at drunomics commentedThx, fixed the issues.
Comment #8
arthur_lorenz CreditAttribution: arthur_lorenz at drunomics commentedComment #9
arthur_lorenz CreditAttribution: arthur_lorenz at drunomics commentedComment #12
opiupdate patch with latest head. Apply nicely on e0dda679298e
Comment #13
tim-dielsThis is working very good, would love to see this in the module.
Latest patch applied nicely.
Comment #14
brayfe CreditAttribution: brayfe commentedApplied this patch cleanly to Drupal 8.5.6 with Block Field version 8.x-1.0-alpha8. So far, works well with the current use case I have. Will report back if I find any issues with adding new provider blocks.
Comment #15
jnettikTested this patch on Drupal 8.6.10 and Block Field 1.0-alpha8 with no issues. This patch feels like a huge improvement to Block Field. I'd also love to see it committed.
Comment #16
Bhanu951 CreditAttribution: Bhanu951 as a volunteer commentedModified Patch for 8.x-1.0-alpha8 build.
Edit:
It seems test cases are failing.
Comment #18
michaellander CreditAttribution: michaellander at Elevated Third commentedComment #19
michaellander CreditAttribution: michaellander at Elevated Third commentedI like the direction this is going. I'm going to take it over and move the options into plugins. This would potentially allow for people to extend the module for more advanced filtering, without requiring us to think through all possible use cases at the moment. An example would be mixing and matching hand picked blocks along with categories, while excluding certain providers and so forth.
Comment #20
michaellander CreditAttribution: michaellander at Elevated Third commentedHere is a first pass at it. Existing settings will not work, so we'll still need to write an update hook. The update hook can cover alpha settings, as well as fixes for anyone using the existing patch. The tests will also need to be updated as I believe some of the selectors have changed. The plugins were heavily influenced by how
Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem
implements them. This should give a ton of flexibility for others to extend how selection works with minimal API commitments on our end.Comment #21
michaellander CreditAttribution: michaellander at Elevated Third commentedComment #22
michaellander CreditAttribution: michaellander at Elevated Third commentedAlright, added:
I think we're close, but would appreciate a few more eyes on it!
Comment #23
michaellander CreditAttribution: michaellander at Elevated Third commentedComment #24
michaellander CreditAttribution: michaellander at Elevated Third commentedMight help if I included the entire patch... how embarrassing.
Comment #25
michaellander CreditAttribution: michaellander at Elevated Third commentedComment #27
switzernThe patch in #24 applies cleanly for me against the most current version of the dev branch. I've patched and tested locally on a site that is running Block Field in production and everything is working as expected.
I've tested:
- All existing Block Fields work as they did before the patch.
- The selection method for all existing fields is set to Blocks and available blocks are configured correctly.
- The selection method can be changed to categories for existing Block Fields without affecting settings or functionality of the existing fields.
- New Block Fields can be created and available blocks can be set without error using either the Blocks or Categories selection method.
Comment #28
michaellander CreditAttribution: michaellander at Elevated Third commentedRe-rolled to latest dev. Fixed some code formatting issues.
Comment #30
michaellander CreditAttribution: michaellander at Elevated Third commentedComment #31
michaellander CreditAttribution: michaellander at Elevated Third commentedComment #32
michaellander CreditAttribution: michaellander at Elevated Third commentedCoding standards
Comment #33
michaellander CreditAttribution: michaellander at Elevated Third commentedUgh, missed 3 lines. Sorry last one.
Comment #34
switzernThe patch in #33 works well. I've applied against the current HEAD of 8.x-1.x-dev in a local instance of a site that is running Block Field in production and tested all of the same use cases I outlined in #27. For clarity, those use cases are:
- All existing Block Fields work as they did before the patch.
- The selection method for all existing fields is set to Blocks and available blocks are configured correctly.
- The selection method can be changed to categories for existing Block Fields without affecting settings or functionality of the existing fields.
- New Block Fields can be created and available blocks can be set without error using either the Blocks or Categories selection method.
Additional use cases tested:
- Selection method on an existing field changed from blocks to categories and updated selection to include a few specific categories.
- Selection method on that same field changed back to blocks and updated to include only a specific few blocks as available selections.
- Changed settings back to original values and everything functions normally.
Comment #36
michaellander CreditAttribution: michaellander at Elevated Third commented