Reviewed & tested by the community
Project:
Body Inject (Content/Ad Injector)
Version:
1.1.x-dev
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
4 Nov 2021 at 06:59 UTC
Updated:
12 Jan 2024 at 09:36 UTC
Jump to comment: Most recent
Comments
Comment #2
marcoka commentedTry something like this
http://www.root.artwaves.de/sharex/04-11-21--20-10-06.jpg
Comment #3
mfby2k commentedremoved becouse its not compatible with drupal 9 and i am ugrading to 9
Comment #4
marcoka commentedI have it running on d9
Comment #5
marcoka commentedThe new version is compatible.
Comment #6
yngvewb commentedI 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?
Comment #7
marcoka commentedHi 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?
Comment #8
yngvewb commentedStill 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
Comment #9
marcoka commentedSet 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
Comment #10
yngvewb commentedI changed to AND but still nothing.
Comment #11
marcoka commentedI am out of ideas now :(
Comment #12
mlncn commentedHi! 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
Comment #13
marcoka commentedThanks 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.
Comment #14
yngvewb commentedSounds fantastic! I will be happy to beta test when you have the dev code posted.
Comment #15
megakeegman commentedOn 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.
Comment #16
megakeegman commentedThe 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.
Comment #17
megakeegman commentedOkay I went ahead and just added it. Please review.
Comment #18
mlncn commentedWe'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...
Comment #19
mlncn commentedWhat 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).
Comment #22
marcoka commentedThank you for your work. I will test the latest dev soon, when i have some time and give feedback.
Comment #23
marcoka commentedI 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.