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.
I am unable to get Insert Block to work with Drupal 8. The issue may be that I'm unable to locate an option to include it in any of the text formats.
At any rate I just see the code [block:block=7] instead of the rendered block.
Thanks for your help!
Comment | File | Size | Author |
---|---|---|---|
#46 | 2648496-46.patch | 6.64 KB | edurenye |
#30 | 2648496-16.patch | 6.58 KB | ahana92 |
#15 | insert_block-not-working-drupal8-2648496-15.patch | 6.42 KB | dhansen |
#6 | insert_block-not-working-drupal8-2648496-6.patch | 6.44 KB | dhansen |
#2 | insert_block_8.x-1.x-dev.patch | 5.71 KB | r.spring |
Comments
Comment #2
r.spring CreditAttribution: r.spring commentedHi. Just getting started with Drupal 8 too, but try this patch. Hopefully it'll work for you too.
Comment #3
SuzeQ CreditAttribution: SuzeQ commentedThanks, that worked!
A couple of notes. When I enabled Insert Block on the Restricted HTML text format I got the following error when attempting to edit any block in the custom block library or any piece of content.
Fatal error: Call to undefined function Drupal\insert_block\Plugin\Filter\url() in /home/lsiku/public_html/modules/insert_block/src/Plugin/Filter/FilterInsertBlock.php on line 56
When disabling Insert Block on the Restricted HTML text format the error disappeared.
I also discovered the token in Drupal 8 is different than in Drupal 7. Instead of [block:block=delta] its [block:blockid]
Thanks greatly for your help!
Comment #4
MSCGuitarman CreditAttribution: MSCGuitarman commentedHi,
I'm also having trouble getting this module to work in drupal 8. I attempted to install the patch but it still will not work. It's my first time installing a patch so maybe I'm not doing it right? I would be grateful if you could give me advise on how I may be able to fix this or if you could upload the patched version of this module as I am starting to get desperate!
Many thanks,
Darren
Comment #5
sic CreditAttribution: sic commentedApplying the patch works, but since in drupal the module info is not really given, you have to embed them like so:
[block:id]
since the id has to be unique in d8 anyways.
works for me!
Comment #6
dhansen CreditAttribution: dhansen at Sevaa Group commentedThere were a couple of issues with the patch already on this ticket and some other things I went ahead and addressed about the module in general:
Changed this to a bug report as well because without the patch the D8 version is not working.
Comment #7
cparkner01 CreditAttribution: cparkner01 commentedI have been trying to get this to work in a new install of Drupal 8 with no success.
I have installed the module, applied the patch, and used the format of "[block:id]". On my site I want to use this to display adsense ads in the middle of the content of a node. I have created a custom block with the content I want displayed and called the block "injected ad" and it shows as having a machine name of "injectedad". In my content I have included [block:injectedad] and it is displaying on my content as "[block:injectedad]" not actually showing the content of the injected ad block. Any help would be appreciated.
Also I have read of people needing to set an input filter to enable insert block in D7 but cannot find anything like this in D8. Any ideas on if and how I can set the input filter to enable insert block on D8?
Comment #8
dhansen CreditAttribution: dhansen at Sevaa Group commented@cparkner01: The filter is the cause of the module not working. It is the component that actually looks at your content and re-renders the short code into the block.
You'll want to configure your text formats. Do that by either going to Configuration > Content authoring > Text format and editors in the admin menu or just going to
/admin/config/content/formats
. Once there, find the text format you want to allow the blocks to appear in and click 'Configure'.Scroll down to the 'Enabled filters' field and you'll find one of the checkboxes marked 'Insert blocks'. Check it, save, and you should have the block appearing once you clear cache on that page, provided the patch was correct and the block short code is right. If the 'Insert blocks' checkbox is not present, double check that you applied the patch correctly to the module.
Bumped this up to critical since the module doesn't work in D8 at all without it.
Comment #9
dhansen CreditAttribution: dhansen at Sevaa Group commentedUpdating the title to clarify and hopefully make this a little easier to find for users.
Comment #10
nehakhadke CreditAttribution: nehakhadke commentedthis patch works for me..
Comment #11
Rick Bergmann CreditAttribution: Rick Bergmann commentedI just tried this patch and got a fatal error:
Fatal error: Declaration of Drupal\insert_block\Plugin\Filter\InsertBlockFilter::process() must be compatible with Drupal\filter\Plugin\FilterInterface::process($text, $langcode) in /var/www/mysite/modules/insert_block/src/Plugin/Filter/InsertBlockFilter.php on line 0
I probably did something wrong when applying the patch? I put the patch file in the root of the insert_block module directory and applied the patch using the pathc command:
patch -p1 < filename.patch
I will try to debug that and post here if I find anything.
Comment #12
cparkner01 CreditAttribution: cparkner01 commented@dhansen
I know I must select the 'insert block' filter in text format and editor, but that option is simply not there, even after applying the patch. I guess I will wait until the next release of the insert block module for D8 to see if this is fixed, until then I will keep trying to solve the issue or find out what I am doing wrong in the patch.
On a side note, a similar module the adsense integration module does something similar, and it manages to display a select-able filter in the text format and editor... however I have run into problems with it and would rather use the insert block module as it gives more flexibility to utilize a block element.
Comment #13
cparkner01 CreditAttribution: cparkner01 commentedAfter applying the patch many times I am getting the following error:
Comment #14
cparkner01 CreditAttribution: cparkner01 commentedJust to clarify, do you have to apply both, that is the patch in #6 and the patch in #2, or just one of them?
After removing and reinstalling everything I am able to apply the patch from #6, which is not throwing an error, but is still not showing the filter on the text format and editor page.
Comment #15
dhansen CreditAttribution: dhansen at Sevaa Group commented@cparkner01 Give this new patch a shot; I think it fixes the process() issue. If not, can you give me a little information about your setup? Drupal and PHP version?
All patches should be assumed to be separate unless marked 'interdiff'.
Comment #16
oana.hulpoi CreditAttribution: oana.hulpoi as a volunteer commentedThe patch in #15 works for me and it fixes the process() issue. And the 'Insert blocks' filter option is there, enable it and the [block:bockid] will be replaced by the block content.
I installed only this patch, without previous two patches.
Thank you!
Comment #17
nehakhadke CreditAttribution: nehakhadke at Invezza Technologies commentedComment #18
rport CreditAttribution: rport commentedI applied patch (15), after I downloaded and enabled the module! The result was that I was unable to access
> admin > configuration > content authoring >text-formats > configure
(any text format).This got me into a whole lot of trouble!
Now I am trying to figure out how to insert a custom block - any suggestions?
Comment #19
dhansen CreditAttribution: dhansen at Sevaa Group commentedMarking this RTBC since there seems to be a consensus that this works.
@rport Using custom blocks was my original goal. This ticket was a 'blocker' for that issue, but I have a solution and I have gone ahead and opened a ticket for it #2844631: Use Custom Blocks (Block Content)
Comment #20
bombjack CreditAttribution: bombjack as a volunteer commentedPatch on #15 Working for me too, no issues noticed thus far.
Comment #21
rport CreditAttribution: rport commented@dhansen Thanks for the update, I'm now following #2844631 - After a couple of hours, I figured it out... I love the idea of custom block shortcodes! - Keep up the good work!
Comment #22
aldovega10 CreditAttribution: aldovega10 commentedI tried this module on Drupal 8.2 and this shortcut does not work [block:block=7] . It just displayed as text, not rendering a block. Please help
Comment #23
dhansen CreditAttribution: dhansen at Sevaa Group commented@aldovega10 Did you apply the patch in this ticket? Did you turn the Insert Block filter on in the text editor settings?
Comment #24
ssambhi CreditAttribution: ssambhi commentedI have tried applying these patches to the currently available version of this module, to no avail. I keep getting errors when I try to apply any of the patches shared here; I'm thinking these patches are for a different version of the module; or I'm just not patching correctly. I haven't been able to see the checkbox to enable this filter in any of the Input Type/Filters section. Can someone share the patched version of this module with me; or advise on how to apply this patch?
Thanks in advance!
PS: I miss Drupal 7 :(
Comment #25
dhansen CreditAttribution: dhansen at Sevaa Group commented@ssambhi The patch procedure between Drupal 7 and Drupal 8 are not different. In many cases patching using Composer on D8 is actually easier because you don't have to manually manage it.
That being said, what errors are you seeing when you apply the patch? Is it while applying the patch or after you try to use the plugin? How far in the patching process can you get?
Comment #26
jsulmar CreditAttribution: jsulmar commented@dhansen Thanks for the patch and advice, but 'insert block' is still not visible for me, and I believe I applied patch #15 properly. Can you advise what I may be doing wrong?
My environment Drupal 8.3.2; PHP 5.6.30; insert_block 8.x
Procedure:
installed module
placed insert_block-not-working-drupal8-2648496-15.patch into modules/insert_block directory
$ patch < insert_block-not-working-drupal8-2648496-15.patch
.. patching file insert_block.module
.. The next patch would delete the file FilterInsertBlock.php,
.. which does not exist! Assume -R? [n] y
.. patching file FilterInsertBlock.php
.. patching file InsertBlockFilter.php
$ drush cr
navigated to admin/config/content/formats/manage/full_html
'insert block' filter does not appear
no warnings or errors are evident
Thanks much.
Comment #27
david.qdoscc CreditAttribution: david.qdoscc commented@jsulmar after patching you should have the new file at this location:
modules/insert_block/src/Plugin/Filter/InsertBlockFilter.php
If not then something went wrong with the patching.
Comment #28
edurenye CreditAttribution: edurenye at ENDPHASYS Technologies commentedRTBC +1 #15 with d8.3
Comment #29
mikebrooks CreditAttribution: mikebrooks at SNP Technologies, Inc. commentedPatch #15 works for us in Drupal 8.4.5. Note: We needed to uninstall and then re-enable the Insert Block module in order for the Insert Block filter option to appear on text format configuration pages.
Comment #30
ahana92 CreditAttribution: ahana92 at Valuebound commentedThis patch works. Please review. You will be able to see the block. Make sure you have selected the Insert block checkbox in ckeditor for whichever editor you are using
Comment #31
mikebrooks CreditAttribution: mikebrooks at SNP Technologies, Inc. commentedHi ahana92,
Patch #15 has been RTBC. Please describe how your new patch improves on insert_block-not-working-drupal8-2648496-15.patch.
Also, the naming of your patch file is incorrect. Please refer to https://www.drupal.org/patch/submit.
Comment #32
chishah92 CreditAttribution: chishah92 at Valuebound commentedI will provide a patch with interdiff.txt which will show the improvisation.
Comment #33
chishah92 CreditAttribution: chishah92 at Valuebound commentedThis Patch fixes the issue. Have provided the inter diff for #15
Comment #34
chishah92 CreditAttribution: chishah92 at Valuebound commentedComment #35
suraj2012 CreditAttribution: suraj2012 as a volunteer and at Valuebound commentedPatch from #33 works. The block is displaying in node pages
Comment #36
Alexandre360 CreditAttribution: Alexandre360 commentedHello,
I'm trying to find a solution to embed block in node content with Drupal 8 and I found this module.
However, I'm afraid to see that a critical issue for the 8.x version is still an issue 2 years after. I wonder if the module is still maintained.
Can somebody point a more robust and future proof solution if there is one ?
Thanks
Comment #37
vinyl_roads@Alexandre360
I need a solution like insert block too (I want to insert some youtube playlists inside body text).
I’ve successfully installed the module on Drupal 8.5.3. Since I didn’t see the Insert Block filter option to appear on text format configuration pages, I’ve applied patch #33 and then I was able to activate the module.
But I can’t see block inside body texte when I use the syntax :
[block:mytheme_powered]
[block:4]
etc.
So, I guess that this module is not ready to be used in production (even if it does exactly what I need).
Have you found an other solution ?
Comment #38
vinyl_roads@Alexandre360
So I’ve found some solutions :
You can make your own filter. Here is a good start :
https://www.lullabot.com/articles/creating-a-custom-filter-in-drupal-8
It is the same approach as this module. Study also the code of the module Insert Block.
You can follow this great post where there is a filter, a button into the editor, it’s awesome ! It uses Media package, especially entity_embed, etc.
https://www.webwash.net/managing-media-assets-using-core-media-in-drupal-8/
(thanks to 4k4 on Drupal SE for the link)
And I also try to debug this module Insert Block. I think the issue in my case is that the block ID is not found in the short code. The Array of all matches is ok but at the end there is no block ID. Not sure if I use the correct version. I need to investigate.
Comment #39
GiorgosKpatch from #33 applies cleanly and resolves issue
RTBC
Comment #40
vinyl_roadsWhat Drupal version do you use ?
@GiorgosK
I’ve made a clean install of Drupal 8.5.3 .
I’ve installed the insert block module with patch. I’m sur the patch is applied (I’ve checked the code).
But the block doesn't show up. I have this error :
I’ve debugged the module (error in foreach loop). I 'll submit an other patch.
But i would like to know why it is working for some users like you and not me on a clean install (just this module installed). Maybe I don’t need to submit my patch.
Comment #41
GiorgosK@viny_roads I am on 8.5.3 and even though patch #33 seemed to apply fine and seemed to be working I just revisited the project again and it does not seem to work after all and get the same message you get in the logs and block does not appear
Comment #42
GiorgosKTried the patch from #15 instead and seems to be working actually
you can insert blocks like this
[block:userregistrationform]
For custom blocks you have to
1. include them in a region and disable them and get their block ID
2. then you can insert them like [block:BLOCKID] (i.e. [block:footerblocksociallinks] )
so as I understand people have tried #15 and it is RTBC
Comment #43
vinyl_roads@GiorgosK
Yes, you’re right : patch#15 is working (clean install of Drupal 8.5.3). Since I’ve debugged patch #30, I’ll check if it is useful to submit my patch.
Comment #44
Nor4a CreditAttribution: Nor4a as a volunteer commentedI can confirm that #15 is working, but #33 is not working
Comment #45
edurenye CreditAttribution: edurenye as a volunteer commentedFixed the problems with #15 and #33 allowing to use both block:block_id and block:module=block_id and avoid error when block is not found. And fixed the regression that added #33, so now you can again render multiple block in a content.
Comment #46
edurenye CreditAttribution: edurenye as a volunteer commentedSorry, for the empty file, here is the good one.
Comment #47
GiorgosK#46 applied cleanly and seems to be working on existing installation of insert_block
Comment #48
iamdroid CreditAttribution: iamdroid commented#46 with current dev works fine for me. Thanks!
Comment #49
GiorgosKProbably should be marked RTBC as per previous 2 posts
Comment #50
vinyl_roads@edurenye Thank you very much for the great job you have done. Patch #46 works very well. It would be nice if maintainers of the module could create a new release.
Comment #51
parashutiki CreditAttribution: parashutiki commented#46 Failed after apply in drupal 8.6.4
Comment #52
vinyl_roads@parashutiki
Are you sure ? I have a Drupal 8.6.4 where this module and patch are installed and it is working. But I didn't try to install module+ patch on a new 8.6.4 clean install.
Comment #53
parashutiki CreditAttribution: parashutiki commented@vinyl_roads i
did not explore deeper, just applied and had not working module. For my case was adjust customized template for module Paragraph. So i can not say what exactly made module not working. May be another modules conflicts or some setting.
Comment #54
renguer0 CreditAttribution: renguer0 as a volunteer commentedHi there. I'm trying the #46 patch but when I insert [block:block_machine_name] or [block:block=1] just to try, I see the text in content, not the block.Forget it. I wasn't enabled "Insert Block" into CKeditor.
Thanks for those who contributed to the development of this module.
Comment #55
proweb.ua CreditAttribution: proweb.ua commentedDrupal 8.8.0
#46 works
Comment #56
Summit CreditAttribution: Summit commentedDrupal 8.8.1.
#46 works please commit.
greetings, Martijn
Comment #57
onejam CreditAttribution: onejam commentedI can confirm it's working on Drupal 8.9.2 and 9.0.2 but it took awhile to figure the strange process of adding insert block to a node content body.
To install:
add this to "require": { } in your composer.json file:
"drupal/insert_block": "1.x-dev",
add these 2 patches to your composer.json:
run: composer update
Administering Insert Block Module:
Enable it in the Text format for your editor (/admin/config/content/formats)
To add the insert block in content, you need the machine name so it looks something like: [block: machine name]. For example: [block: testinginsertblock]
You can find the machine name in your block configuration settings page.
Here's the odd part, you need to place the block in a region (like main content region) and disable the block.
Now add the tag [block: machine name] to the content page you want it to appear.
I have no idea about the permission settings since i couldn't find any info on this?
Thanks to GiorgosK (comment #42), otherwise i would have been completely lost on how the hell you administer this module.
Comment #58
mjchadwick@onejam thank you for the detailed explanation in #57. I was able to get it to work because of it.
One correction, though:
[block: block-id]
(note: with a space) did not work. What did work was[block:block-id]
, though.Comment #59
dadderley CreditAttribution: dadderley as a volunteer commentedThank you onejam
I applied these patches:
Drupal 8 - Filter not Visible": "https://www.drupal.org/files/issues/2018-06-08/2648496-46.patch"
Drupal 9 Compatibility": "https://www.drupal.org/files/issues/2020-06-19/insert_block-d9-compatibi..."
This works in Drupal 9.1.7
I am updating a D7 site where I used this module's functionality quite a bit.
It would be really cool if these changes could find their way into an official release of the module.
It is a little scary using a dev module from 2014 on a production site in 2021.
Comment #60
John_B CreditAttribution: John_B commentedDoes not work for custom blocks. For an updated version see https://www.drupal.org/project/insert_block/issues/3151591#comment-14156645
Comment #61
akozoriz CreditAttribution: akozoriz as a volunteer commentedComment #62
Summit CreditAttribution: Summit commentedHi comment #60; https://www.drupal.org/project/insert_block/issues/2648496#comment-14156649 helpt me a lot.
May be go further on that proposed thread and close this one?
greetings, Martijn
Comment #63
akozoriz CreditAttribution: akozoriz as a volunteer commented