I installed it on latest drupal 8 version but nothing is injected. the rules are shown in the image.

CommentFileSizeAuthor
screencapture.png176.42 KBmfby2k
Command icon 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:

Comments

mfby2k created an issue. See original summary.

marcoka’s picture

mfby2k’s picture

removed becouse its not compatible with drupal 9 and i am ugrading to 9

marcoka’s picture

I have it running on d9

marcoka’s picture

The new version is compatible.

yngvewb’s picture

I can't get it to work either. I first tried as mfby2k did https://nimb.ws/ldcI6B and then as marcoka suggested https://nimb.ws/YhM7PJ but nothing gets injected into the body. I tried both the released version and the dev version. What am I doing wrong?

marcoka’s picture

Hi strage, the image i posted was a working setting here. Can you please raise the characters to 500 and also insert more text to your testnode?

yngvewb’s picture

Still nothing happens when I change to 500 and I checked that I have added much more than 500 characters in the node https://nimb.ws/LR92CK

marcoka’s picture

Set your FIRST AND/OR to AND please. Then you have the exact settings i had. If that works i have a bug in the and/or switch

yngvewb’s picture

I changed to AND but still nothing.

marcoka’s picture

I am out of ideas now :(

mlncn’s picture

Version: 1.0.1 » 1.1.x-dev

Hi! Pretty sure the reason nothing is injected for some people is because the code presumes layout builder is active, and looks for the body field there.

No layout builder, the body field is not found, nothing is inserted.

I'm in the process of a pretty thorough overhaul of the code that fixes this; i wonder if that would be accepted as a 2.0.x version? I'd be happy to co-maintain, or just put the code in this issue.

Aside from making sure it works without layout builder, i am also making it work with blocks that are not content blocks.

And maybe doing the output ultimately through block_token module, because i think that would resolve the problems noted in the README about HTML tags being rendered as text instead of interpreted as HTML code— i think the cause is the fact that text formats run twice, once for the block and again on the output of the block in the node, and using tokens (properly configured on the node to be substituted last, after all input formats run) fixes that.

I might try out the idea of automatically creating token blocks in this module, if that's all right? It would be best as a feature of token module but we could move forward with a lightweight version in body_inject, basically doing in the background the least-configurable approach described here #3303555: Support un-placed blocks

marcoka’s picture

Thanks for alle the input.
Oh, yes you are right it works only with layout builder as i used that for all my sites and didn´t think about the other case.
The idea with token sounds interesting, but it makes the module dependend on a secnd one.
Ideas sound good to me. Checked your profile, will add you to the maintainers in a minute.

yngvewb’s picture

Sounds fantastic! I will be happy to beta test when you have the dev code posted.

megakeegman’s picture

On testing the current fork, the blocks seem not to inject and the profile listings show "invalid block/deleted block". I have verified that the plugin ids actually are being stored by the form. At least for the profile list, the block references are showing up NULL because the code is still trying to load them via BlockContent::load(), which of course does not work since this is looking for custom blocks.

megakeegman’s picture

The merge request has been updated to fix several issues:
- injection now works for both content blocks and blocks
- the block reference field on both the profile form and list now displays the human readable label rather than the id (once again)

Some thorough testing of all functionality would not hurt, but so far at least the "insert after paragraph.." seems to be working fine.
I am thinking about adding back the machine readable name of the block to the profile form, though. A good example of a standard format for showing both human readable and machine readable names in an option field could help.

megakeegman’s picture

Status: Active » Needs review

Okay I went ahead and just added it. Please review.

mlncn’s picture

Status: Needs review » Reviewed & tested by the community

We're confident that this is a significant fix/enhancement with no loss of capability, and so good to release in the same branch.

Fix: Works with standard non-layout-builder content as well as layout builder.

Enhancement: Allows use of Code and Config-based blocks, including [Simple Block](https://www.drupal.org/project/simple_block), as well as Content blocks.

Even though loading blocks through block manager works for content blocks also, we continued to load through block content directly to prevent any unexpected changes: https://git.drupalcode.org/issue/body_inject-3247600/-/compare/1.1.x...3...

mlncn’s picture

What we did not do is the more ambitious 'fake placement' of blocks so that the config could be saved, and then they could be inserted. So many blocks that are now selectable will not actually work, because without configuration they are meaningless (think Social Simple).

  • mlncn committed 60b97b3 on 1.1.x
    Issue #3247600: Nothing injected
    
marcoka’s picture

Thank you for your work. I will test the latest dev soon, when i have some time and give feedback.

marcoka’s picture

I started working on a D10 only version.
Token block 2 is required for that to work
Testing it currently and will report back.

Works so far on D10 and token block 2. But with the layoutbuilder i need to fix something.