I am unable to access parent-node tokens from child-paragraphs in the default installed setup. I think that paragraph users would benefit by including first class support for either (or both).

1. parent node token accessibility from entity-referenced paragraphs and paragraph library entities.
2. passing arguments from parent nodes and parent paragraphs to paragraph children (based on Rules component patterns)

I think this would make paragraphs more component and template like and enable better reuse.

Thanks

Issue fork paragraphs-3067265

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

Syntapse created an issue. See original summary.

Syntapse’s picture

Most other features of drupal have contextual arguments or ability to access parent context (views, panels, blocks). This post is almost a year old and this would still be a great feature and create countless more applications for paragraphs. Does anyone have an opinion on this or have any workarounds on how to achieve this?

jasonluttrell’s picture

+1 for this feature.

capellic’s picture

I am trying to use the Entity Extra Fields module to add a pseudo field to a paragraph that will show a field value from its host node via tokens. I saw a rumor out there that that something like `[paragraph:parent_entity:field_event_location]` would work but it doesn't.

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

d70rr3s’s picture

rromore’s picture

Status: Active » Needs review

Tested MR !28 and it works.

Syntapse’s picture

Issue summary: View changes
Syntapse’s picture

Title: Paragraph templates: paragraphs parent node token access and argument passing. » Paragraph templates: unable to access parent-node tokens from child-paragraphs in the default installed setup
Syntapse’s picture

Tested in dev version.

This is works for basic entity-ref'd paragraphs and paragraph library entities!

e.g.

parent node.body = "hello world"

(entity-ref) simple paragraph.text = [node.body] => "hello world"

(linked library) simple paragraph.text => [node.body] => "hello world"

context just works in both cases

@d70rr3s thanks!

d70rr3s’s picture

Thanks, but the credit goes to Clive at Drupal Answers, I just made a MR with it.

jrockowitz’s picture

StatusFileSize
new2.22 KB

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

fathershawn’s picture

Rebased the branch in the issue fork on recent changes in `8.x-1.x` and pushed to a new branch to preserve other's prior work. Opened a new MR with the rebased code.

I've also added a patch file for those who prefer it.

fathershawn’s picture

StatusFileSize
new6.43 KB
dieterholvoet’s picture

Maybe parent could be a better token name than parent_entity? Simpler, + the same as taxonomy's parent token.

berdir’s picture

Title: Paragraph templates: unable to access parent-node tokens from child-paragraphs in the default installed setup » Add a parent entity token for paragraphs
Status: Needs review » Needs work

I'm very confused why this is mixing templates and tokens. templates usually implies twig templates, and twig templates don't resolve tokens. Neither seems "default installed setup" relevant, tokens either exist or they don't, it's not a default setup/configuration thing.

dieterholvoet changed the visibility of the branch 3067265-paragraph-templates-paragraphs to hidden.

dieterholvoet’s picture

Status: Needs work » Needs review
alphex’s picture

This patch breaks against paragraphs 1.22.

alphex’s picture

Status: Needs review » Needs work

This patch breaks against 1.23 now, also.

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