Problem/Motivation
When using a view that has block_content as entity type id, the following warning is generated.
Warning: Undefined array key "#theme" in Drupal\swiper_formatter\Plugin\views\style\SwiperFormatterStyle->render() (line 234 of modules/contrib/swiper_formatter/src/Plugin/views/style/SwiperFormatterStyle.php).
Steps to reproduce
1. Navigate to /admin/structure/block-content, and create a Block Type if you don't have any.
2. Create a few block contents.
3. Create a view that shows "Content Block".
4. Apply the swiper formatter style plugin.
5. If the view is a block, place it somewhere. I used a block in layout builder.
6. Navigate to the page and observe the warning.
Proposed resolution
When debugging this, I noticed that the block content had the key '#entity_type'. So, my proposition is to add an extra case in the if statement that checks for the entity to have it work for this case. I compared with nodes, and indeed nodes don't have it, but block_content has it.
Remaining tasks
None.
User interface changes
None.
API changes
None.
Data model changes
None.
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | Screenshot August 21 2024 21:59:33.png | 324.68 KB | bbu23 |
| #4 | swiper_formatter-3403505-mr-2-2023-12-15.patch | 1.17 KB | chrisolof |
Issue fork swiper_formatter-3403505
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3403505-warning-undefined-array
changes, plain diff MR !2
Comments
Comment #3
bbu23Comment #4
chrisolofI just ran into this bug while attempting to display ECK entities in a views block using the swiper formatter views plugin. The changes in MR 2 fix the issue for me. Thanks @bbu23!
Attached is an immutable patch snapshot of MR 2, as it stands today.
Comment #6
nk_ commentedThank you all! It was finally committed in the new release, the last one supporting Drupal 8.8 and 9. A brand new branch 2.0.x with quite some new features is there and recommended for a future use.
Comment #8
nk_ commentedComment #9
bbu23It seems that the tag 1.0.7 was created prior to the commit that fixes this in 1.0.x.
Not sure if you're aware of this, so the change + another one are not included in 1.0.7
Comment #10
bbu23Temporary solution for 1.0.7 is applying the commit patch (if anyone needs it): https://git.drupalcode.org/project/swiper_formatter/-/commit/59bda303dea...