Closed (fixed)
Project:
Block field
Version:
8.x-1.x-dev
Component:
Miscellaneous
Priority:
Normal
Category:
Feature request
Assigned:
Issue tags:
Reporter:
Created:
5 May 2017 at 16:52 UTC
Updated:
16 Apr 2019 at 16:44 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
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 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 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 commentedThx, fixed the issues.
Comment #8
arthur_lorenz commentedComment #9
arthur_lorenz 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 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 commentedModified Patch for 8.x-1.0-alpha8 build.
Edit:
It seems test cases are failing.
Comment #18
michaellander commentedComment #19
michaellander 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 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\EntityReferenceItemimplements 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 commentedComment #22
michaellander commentedAlright, added:
I think we're close, but would appreciate a few more eyes on it!
Comment #23
michaellander commentedComment #24
michaellander commentedMight help if I included the entire patch... how embarrassing.
Comment #25
michaellander 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 commentedRe-rolled to latest dev. Fixed some code formatting issues.
Comment #30
michaellander commentedComment #31
michaellander commentedComment #32
michaellander commentedCoding standards
Comment #33
michaellander 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 commented