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.

Issue fork markup-2981744

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

Scheepers de Bruin created an issue. See original summary.

Scheepers de Bruin’s picture

anybody’s picture

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

anybody’s picture

I'll have a look as soon as possible. If someone has the time earlier, please create an entity patch.

anybody’s picture

PS: #2 works perfectly for nodes, thank you!

anybody’s picture

Status: Active » Reviewed & tested by the community

RTBC. As said in #3 it would make sense to extend this on all kind of entities (the Drupal 8 way ;))

anybody’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new1.36 KB

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

anybody’s picture

StatusFileSize
new1.32 KB

Removed one unrequired line.

anybody’s picture

Status: Needs work » Needs review
StatusFileSize
new1.33 KB

Another fix.

anybody’s picture

The question is now... does the same make sense for the widget? Some tokens might be empty on "create" while they are available on edit...

scottsawyer’s picture

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

Tokens are allowed, but keep in mind, not all tokens are available in every context. Please consult the module / token provider for more details.

anybody’s picture

My thoughts are, tokens are something that probably need better explanations for end-users and are more of a site-builder tool

Well, markup field is for sitebuilders, isn't it? The end-user simply sees the replaced token.

Tokens are allowed, but keep in mind, not all tokens are available in every context. Please consult the module / token provider for more details.

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?

anybody’s picture

Status: Needs review » Needs work

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

anybody’s picture

Title: Allow parent node token replacement » Add submodule for token support
coaston’s picture

Thank you Anybody,

Patch #9 saved me! Now I can use tokens with markup module. That is amazing!

bcobin’s picture

Lovin' this - thank you!

samitk’s picture

Assigned: Unassigned » samitk

I am working to Add submodule for token support.

samitk’s picture

Assigned: samitk » Unassigned
Status: Needs work » Needs review
StatusFileSize
new5.02 KB

Hi Anybody, I have added a submodule for token support.

Please review.

Thanks
Samit K.

anybody’s picture

Status: Needs review » Needs work

@samit.310@gmail.com please provide this as MR. Thanks!

samitk’s picture

Status: Needs work » Needs review

Hi @Anybody,

MR is created please review and merge.

https://git.drupalcode.org/project/markup/-/merge_requests/5

Thanks
Samit K

miguel andrade’s picture

Just tried #18 and the MR5, and they didn't work. (nothing happened) I'm using D10.
using 'drupal/markup:^2.0@beta'

davidiio made their first commit to this issue’s fork.