This version does not allow tokens from the parent node to be replaced in the value.
It would be very useful, if only for the node ID, to construct links, etc.
| Comment | File | Size | Author |
|---|---|---|---|
| #18 | 2981744-18.patch | 5.02 KB | samitk |
| #9 | markup-add-entity-token-support-2981744-9.patch | 1.33 KB | anybody |
| #2 | 2981744-allow-parent-node-token-replacement.patch | 843 bytes | Scheepers de Bruin |
Issue fork markup-2981744
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
Comment #2
Scheepers de Bruin commentedComment #3
anybody@Scheepers de Bruin: Thank you, this is a great idea and nice patch. Is it possible to use entities instead of nodes?
That would make it "the Drupal 8 way" and support all kind of entities (Taxonomies, Users, ECK, custom ...) perhaps we can have a look at other modules which solve this?
Comment #4
anybodyI'll have a look as soon as possible. If someone has the time earlier, please create an entity patch.
Comment #5
anybodyPS: #2 works perfectly for nodes, thank you!
Comment #6
anybodyRTBC. As said in #3 it would make sense to extend this on all kind of entities (the Drupal 8 way ;))
Comment #7
anybodyReverting my RTBC... markup field can be used in any kind of entity, so we should ensure all entity types / parent entity type to be handled as tokens.
Patch attached. Please test and review.
Comment #8
anybodyRemoved one unrequired line.
Comment #9
anybodyAnother fix.
Comment #10
anybodyThe question is now... does the same make sense for the widget? Some tokens might be empty on "create" while they are available on edit...
Comment #11
scottsawyerI just tested the patch in #9 and it's a nice little solution for me, works with an ECK entity.
As for the question you pose, whether it makes sense due to some tokens being empty on "create"? Yes, that is a problem, but there are always tokens that have various issues being populated due to context, node / entity ids being notorious examples.
My thoughts are, tokens are something that probably need better explanations for end-users and are more of a site-builder tool ( though some may disagree ). While it's probably something the token module should handle, I think this can be easily mitigated with some simple text like:
Comment #12
anybodyWell, markup field is for sitebuilders, isn't it? The end-user simply sees the replaced token.
No, there won't be support by the module maintainers. It's open source.
But what we might add is the token browser and a link to the token explanation like in other places. Feel free to create a modified patch. Furthermore I'm not sure if we should check for permissions?
Comment #13
anybodyAfter thinking about this for some time, I think this should be separated into a sub-module. The functionality is not needed in many cases and can be an alternative or addition to markup_twig, which is also a separate module. Issues like #3052621: Allow empty markup field show that this may also have impact on things like validation or rendering.
Comment #14
anybodyComment #15
coaston commentedThank you Anybody,
Patch #9 saved me! Now I can use tokens with markup module. That is amazing!
Comment #16
bcobin commentedLovin' this - thank you!
Comment #17
samitk commentedI am working to Add submodule for token support.
Comment #18
samitk commentedHi Anybody, I have added a submodule for token support.
Please review.
Thanks
Samit K.
Comment #19
anybody@samit.310@gmail.com please provide this as MR. Thanks!
Comment #21
samitk commentedHi @Anybody,
MR is created please review and merge.
https://git.drupalcode.org/project/markup/-/merge_requests/5
Thanks
Samit K
Comment #22
miguel andrade commentedJust tried #18 and the MR5, and they didn't work. (nothing happened) I'm using D10.
using 'drupal/markup:^2.0@beta'