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!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

SuzeQ created an issue. See original summary.

r.spring’s picture

Hi. Just getting started with Drupal 8 too, but try this patch. Hopefully it'll work for you too.

SuzeQ’s picture

Thanks, 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!

MSCGuitarman’s picture

Hi,

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

sic’s picture

Applying 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!

dhansen’s picture

Category: Support request » Bug report
Status: Active » Needs review
FileSize
6.44 KB

There 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:

  • Old patch was based out of the module directory and had a lot of unneeded header info. Now properly based out of the insert_block directory and there's no header.
  • Filter/Filter Class naming convention fixed from FilterInsertBlock to InsertBlockFilter. Oddly, the pattern of 'filter_insert_block' for the ID is pretty consistent, so that has not changed (which would break the site of anyone using the patch already if it did, so that is good).
  • No longer using any depreciated or missing functions
  • Moved the actual filter functionality back into the filter. I don't see the utility of having it in the module file, it really serves just to scatter the code when it's separate from the actual filter.

Changed this to a bug report as well because without the patch the D8 version is not working.

cparkner01’s picture

I 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?

dhansen’s picture

Priority: Normal » Critical

@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.

dhansen’s picture

Title: Not working in Drupal 8 » Not working in Drupal 8 - Filter not Visible

Updating the title to clarify and hopefully make this a little easier to find for users.

nehakhadke’s picture

this patch works for me..

Rick Bergmann’s picture

I 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.

cparkner01’s picture

@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.

cparkner01’s picture

After applying the patch many times I am getting the following error:

Fatal error: Declaration of Drupal\insert_block\Plugin\Filter\InsertBlockFilter::process() must be compatible with Drupal\filter\Plugin\FilterInterface::process($text, $langcode) in /home/dtwjzib/public_html/d8/modules/insert_block/src/Plugin/Filter/InsertBlockFilter.php on line 0
cparkner01’s picture

Just 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.

dhansen’s picture

@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'.

oana.hulpoi’s picture

The 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!

nehakhadke’s picture

rport’s picture

I 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!

  1. To fix the problem, I had to;
  2. delete the "insert_block" module folder;
  3. download the "insert_block" module (again)
  4. apply the patch
  5. uninstall the patched "insert_block" module
  6. delete the "insert_block" module folder;
  7. download the "insert_block" module (again)
  8. download & apply the patch (15)
  9. enable the module

Now I am trying to figure out how to insert a custom block - any suggestions?

dhansen’s picture

Status: Needs review » Reviewed & tested by the community

Marking 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)

bombjack’s picture

Patch on #15 Working for me too, no issues noticed thus far.

rport’s picture

@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!

aldovega10’s picture

I 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

dhansen’s picture

@aldovega10 Did you apply the patch in this ticket? Did you turn the Insert Block filter on in the text editor settings?

ssambhi’s picture

I 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 :(

dhansen’s picture

@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?

jsulmar’s picture

@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.

david.qdoscc’s picture

@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.

edurenye’s picture

RTBC +1 #15 with d8.3

mikebrooks’s picture

Patch #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.

ahana92’s picture

FileSize
6.58 KB

This 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

mikebrooks’s picture

Hi 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.

chishah92’s picture

Assigned: Unassigned » chishah92
Status: Reviewed & tested by the community » Needs work

I will provide a patch with interdiff.txt which will show the improvisation.

chishah92’s picture

Status: Needs work » Needs review
FileSize
6.58 KB
1.11 KB

This Patch fixes the issue. Have provided the inter diff for #15

chishah92’s picture

Assigned: chishah92 » Unassigned
suraj2012’s picture

Status: Needs review » Reviewed & tested by the community

Patch from #33 works. The block is displaying in node pages

Alexandre360’s picture

Hello,

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

vinyl_roads’s picture

@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 ?

vinyl_roads’s picture

@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.

GiorgosK’s picture

patch from #33 applies cleanly and resolves issue
RTBC

vinyl_roads’s picture

What 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 :

Notice: Undefined offset: 1 in Drupal\insert_block\Plugin\Filter\InsertBlockFilter->process() (line 54 of modules/contrib/insert_block/src/Plugin/Filter/InsertBlockFilter.php).
Warning: array_flip(): Can only flip STRING and INTEGER values! in Drupal\Core\Entity\EntityStorageBase->loadMultiple() (line 227 of core/lib/Drupal/Core/Entity/EntityStorageBase.php).

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.

GiorgosK’s picture

Status: Reviewed & tested by the community » Needs work

@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

Notice: Undefined offset: 1 in Drupal\insert_block\Plugin\Filter\InsertBlockFilter->process() (line 54 of /home/domain.com/modules/contrib/insert_block/src/Plugin/Filter/InsertBlockFilter.php) #0 /home/domain.com/core/includes/bootstrap.inc(582): _drupal_error_handler_real(8, 'Undefined offse...', '/home/domain.com...', 54, Array) #1 /home/domain.com/modules/contrib/insert_block/src/Plugin/Filter/InsertBlockFilter.php(54): _drupal_error_handler(8, 'Undefined offse...', '/home/domain.com...', 54, Array) #2 /home/domain.com/core/modules/filter/src/Element/ProcessedText.php(118): Drupal\insert_block\Plugin\Filter\InsertBlockFilter->process('<div class="row...', 'en') #3 [internal function]: Drupal\filter\Element\ProcessedText::preRenderText(Array) #4 /home/domain.com/core/lib/Drupal/Core/Render/Renderer.php(378): call_user_func(Array, Array) #5 /home/domain.com/core/lib/Drupal/Core/Render/Renderer.php(195): Drupal\Core\Render\Renderer->doRender(Array, false) #6 /home/domain.com/core/lib/Drupal/Core/Template/TwigExtension.php(490): Drupal\Core\Render\Renderer->render(Array) #7 /home/domain.com/sites/default/files/php/twig/5afd2f2c0408c_field.html.twig_ZQFut_FJeb1s62ByCJKZXJS-y/vW8qB_b14AUIBD42-MpR4gOvMpBsINVX9LsuFHQcqpU.php(91): Drupal\Core\Template\TwigExtension->escapeFilter(Object(Drupal\Core\Template\TwigEnvironment), Array, 'html', NULL, true) #8 /home/domain.com/vendor/twig/twig/lib/Twig/Template.php(432): __TwigTemplate_591a77cf0c6a82e481a1a891b555190e6e511b8f1346e4e850c18fd3aab97381->doDisplay(Array, Array) #9 /home/domain.com/vendor/twig/twig/lib/Twig/Template.php(403): Twig_Template->displayWithErrorHandling(Array, Array) #10 /home/domain.com/vendor/twig/twig/lib/Twig/Template.php(411): Twig_Template->display(Array) #11 /home/domain.com/core/themes/engines/twig/twig.engine(64): Twig_Template->render(Array) #12 /home/domain.com/core/lib/Drupal/Core/Theme/ThemeManager.php(384): twig_render_template('themes/custom/t...', Array) #13 /home/domain.com/core/lib/Drupal/Core/Render/Renderer.php(437): Drupal\Core\Theme\ThemeManager->render('field', Array) #14 /home/domain.com/core/lib/Drupal/Core/Render/Renderer.php(450): Drupal\Core\Render\Renderer->doRender(Array) #15 /home/domain.com/core/lib/Drupal/Core/Render/Renderer.php(195): Drupal\Core\Render\Renderer->doRender(Array, false) #16 /home/domain.com/core/lib/Drupal/Core/Template/TwigExtension.php(490): Drupal\Core\Render\Renderer->render(Array) #17 /home/domain.com/sites/default/files/php/twig/5afd2f2c0408c_block.html.twig_BAeYge3Yn0gxnzE45Z-T-Ce-x/v7D2rUfCfiNTCV4VTq9FSxMRCiR-iI9_MUkf0Y9l-hY.php(87): Drupal\Core\Template\TwigExtension->escapeFilter(Object(Drupal\Core\Template\TwigEnvironment), Array, 'html', NULL, true) #18 /home/domain.com/vendor/twig/twig/lib/Twig/Template.php(215): __TwigTemplate_6ab046e8652cb00aabc791125ecdcb948817f54ef32fffc3607183c22182748e->block_content(Array, Array) #19 /home/domain.com/sites/default/files/php/twig/5afd2f2c0408c_block.html.twig_BAeYge3Yn0gxnzE45Z-T-Ce-x/v7D2rUfCfiNTCV4VTq9FSxMRCiR-iI9_MUkf0Y9l-hY.php(74): Twig_Template->displayBlock('content', Array, Array) #20 /home/domain.com/vendor/twig/twig/lib/Twig/Template.php(432): __TwigTemplate_6ab046e8652cb00aabc791125ecdcb948817f54ef32fffc3607183c22182748e->doDisplay(Array, Array) #21 /home/domain.com/vendor/twig/twig/lib/Twig/Template.php(403): Twig_Template->displayWithErrorHandling(Array, Array) #22 /home/domain.com/vendor/twig/twig/lib/Twig/Template.php(411): Twig_Template->display(Array) #23 /home/domain.com/core/themes/engines/twig/twig.engine(64): Twig_Template->render(Array) #24 /home/domain.com/core/lib/Drupal/Core/Theme/ThemeManager.php(384): twig_render_template('themes/custom/t...', Array) #25 /home/domain.com/core/lib/Drupal/Core/Render/Renderer.php(437): Drupal\Core\Theme\ThemeManager->render('block', Array) #26 /home/domain.com/core/lib/Drupal/Core/Render/Renderer.php(450): Drupal\Core\Render\Renderer->doRender(Array) #27 /home/domain.com/core/lib/Drupal/Core/Render/Renderer.php(195): Drupal\Core\Render\Renderer->doRender(Array, false) #28 /home/domain.com/core/lib/Drupal/Core/Template/TwigExtension.php(490): Drupal\Core\Render\Renderer->render(Array) #29 /home/domain.com/sites/default/files/php/twig/5afd2f2c0408c_page--fullwidth.html.twig_jIHtAY26yOq_XlJXnIMX-hDzI/f3jt4mUO0cfWmawIfGz_k_KruNUHJvDqqAx3AkrCKvA.php(298): Drupal\Core\Template\TwigExtension->escapeFilter(Object(Drupal\Core\Template\TwigEnvironment), Array, 'html', NULL, true) #30 /home/domain.com/vendor/twig/twig/lib/Twig/Template.php(215): __TwigTemplate_f12895221ed059da23ba9f61c938db18244469ba5075233ee4d0d7527ca5ad63->block_footer(Array, Array) #31 /home/domain.com/sites/default/files/php/twig/5afd2f2c0408c_page--fullwidth.html.twig_jIHtAY26yOq_XlJXnIMX-hDzI/f3jt4mUO0cfWmawIfGz_k_KruNUHJvDqqAx3AkrCKvA.php(125): Twig_Template->displayBlock('footer', Array, Array) #32 /home/domain.com/vendor/twig/twig/lib/Twig/Template.php(432): __TwigTemplate_f12895221ed059da23ba9f61c938db18244469ba5075233ee4d0d7527ca5ad63->doDisplay(Array, Array) #33 /home/domain.com/vendor/twig/twig/lib/Twig/Template.php(403): Twig_Template->displayWithErrorHandling(Array, Array) #34 /home/domain.com/vendor/twig/twig/lib/Twig/Template.php(411): Twig_Template->display(Array) #35 /home/domain.com/core/themes/engines/twig/twig.engine(64): Twig_Template->render(Array) #36 /home/domain.com/core/lib/Drupal/Core/Theme/ThemeManager.php(384): twig_render_template('themes/custom/t...', Array) #37 /home/domain.com/core/lib/Drupal/Core/Render/Renderer.php(437): Drupal\Core\Theme\ThemeManager->render('page', Array) #38 /home/domain.com/core/lib/Drupal/Core/Render/Renderer.php(195): Drupal\Core\Render\Renderer->doRender(Array, false) #39 /home/domain.com/core/lib/Drupal/Core/Template/TwigExtension.php(490): Drupal\Core\Render\Renderer->render(Array) #40 /home/domain.com/sites/default/files/php/twig/5afd2f2c0408c_html.html.twig_DlTcN0CLQ_M__x4XSPDHdaVuy/UqxtzJcxv8Xt_hwvJTSdFhkkzNv0FrmbER0g4hu7A4w.php(95): Drupal\Core\Template\TwigExtension->escapeFilter(Object(Drupal\Core\Template\TwigEnvironment), Array, 'html', NULL, true) #41 /home/domain.com/vendor/twig/twig/lib/Twig/Template.php(432): __TwigTemplate_070978e6fd79c34beb118e7464cc01c188a625f19dfbd3180aea2641a9900016->doDisplay(Array, Array) #42 /home/domain.com/vendor/twig/twig/lib/Twig/Template.php(403): Twig_Template->displayWithErrorHandling(Array, Array) #43 /home/domain.com/vendor/twig/twig/lib/Twig/Template.php(411): Twig_Template->display(Array) #44 /home/domain.com/core/themes/engines/twig/twig.engine(64): Twig_Template->render(Array) #45 /home/domain.com/core/lib/Drupal/Core/Theme/ThemeManager.php(384): twig_render_template('themes/custom/t...', Array) #46 /home/domain.com/core/lib/Drupal/Core/Render/Renderer.php(437): Drupal\Core\Theme\ThemeManager->render('html', Array) #47 /home/domain.com/core/lib/Drupal/Core/Render/Renderer.php(195): Drupal\Core\Render\Renderer->doRender(Array, false) #48 /home/domain.com/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(147): Drupal\Core\Render\Renderer->render(Array) #49 /home/domain.com/core/lib/Drupal/Core/Render/Renderer.php(582): Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() #50 /home/domain.com/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(148): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure)) #51 /home/domain.com/core/lib/Drupal/Core/EventSubscriber/MainContentViewSubscriber.php(90): Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\CurrentRouteMatch)) #52 [internal function]: Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object(Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent), 'kernel.view', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher)) #53 /home/domain.com/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(111): call_user_func(Array, Object(Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent), 'kernel.view', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher)) #54 /home/domain.com/vendor/symfony/http-kernel/HttpKernel.php(156): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view', Object(Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent)) #55 /home/domain.com/vendor/symfony/http-kernel/HttpKernel.php(68): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1) #56 /home/domain.com/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #57 /home/domain.com/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #58 /home/domain.com/core/modules/page_cache/src/StackMiddleware/PageCache.php(184): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #59 /home/domain.com/core/modules/page_cache/src/StackMiddleware/PageCache.php(121): Drupal\page_cache\StackMiddleware\PageCache->fetch(Object(Symfony\Component\HttpFoundation\Request), 1, true) #60 /home/domain.com/core/modules/page_cache/src/StackMiddleware/PageCache.php(75): Drupal\page_cache\StackMiddleware\PageCache->lookup(Object(Symfony\Component\HttpFoundation\Request), 1, true) #61 /home/domain.com/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #62 /home/domain.com/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(50): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #63 /home/domain.com/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #64 /home/domain.com/core/lib/Drupal/Core/DrupalKernel.php(664): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #65 /home/domain.com/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request)) #66 {main}.
GiorgosK’s picture

Status: Needs work » Reviewed & tested by the community

Tried 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

vinyl_roads’s picture

@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.

Nor4a’s picture

I can confirm that #15 is working, but #33 is not working

edurenye’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
867 bytes
0 bytes

Fixed 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.

edurenye’s picture

FileSize
6.64 KB

Sorry, for the empty file, here is the good one.

GiorgosK’s picture

#46 applied cleanly and seems to be working on existing installation of insert_block

iamdroid’s picture

#46 with current dev works fine for me. Thanks!

GiorgosK’s picture

Status: Needs review » Reviewed & tested by the community

Probably should be marked RTBC as per previous 2 posts

vinyl_roads’s picture

@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.

parashutiki’s picture

#46 Failed after apply in drupal 8.6.4

vinyl_roads’s picture

@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.

parashutiki’s picture

@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.

renguer0’s picture

Hi 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.

proweb.ua’s picture

Drupal 8.8.0
#46 works

Summit’s picture

Drupal 8.8.1.
#46 works please commit.
greetings, Martijn

onejam’s picture

I 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:

"extra": {
        "enable-patching": true,
        "patches": {
            "drupal/insert_block": {
                "2648496-46: Not working in Drupal 8 - Filter not Visible": "https://www.drupal.org/files/issues/2018-06-08/2648496-46.patch",
                "3151591-3: Drupal 9 Compatibility": "https://www.drupal.org/files/issues/2020-06-19/insert_block-d9-compatibility-3151591-3.patch"
        }

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.

mjchadwick’s picture

@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.

dadderley’s picture

Thank 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.

John_B’s picture

Does not work for custom blocks. For an updated version see https://www.drupal.org/project/insert_block/issues/3151591#comment-14156645

akozoriz’s picture

Assigned: Unassigned » akozoriz
Summit’s picture

Hi 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

akozoriz’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.