Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hey, thanks for this great module!
I've run into a issue where I have a Paragraph bundle that contains image fields. I'm using the File Field paths module along with ImageField Tokens and would like to use tokens from the node on the File name and Alt tag. When setting up the image field inside the bundles, I am unable to specify any tokens from the node that the bundle will be displayed on.
Is this something that can currently be achieved I may have overlooked? Or is this somethign you would consider adding?
There is a similar issue over in the Field Collection issue queue.
Thanks
Comments
Comment #1
Volker23 CreditAttribution: Volker23 commentedI just found out that tokens are not really supported. Please count me in, i'd love to see that feature in paragraphs, which is my favorite content structure module right now. Thanks for your work!
Comment #2
Alexandre360 CreditAttribution: Alexandre360 commented+1 to this.
Example of usefulness of this :
Now you probably want to have logic file path for your images in your slider, for example : /images/sliders/[node:title]. But it's not possible because you can't get access to the node title that handle the slider paragraph you just created.
Comment #3
aitala CreditAttribution: aitala commentedI would find it useful as well..
Thanks,
Eric
Comment #4
onehandsomedog CreditAttribution: onehandsomedog commented+1 Would lke this available
Comment #5
Nchase CreditAttribution: Nchase as a volunteer commentedalso intersting in conjunction with filefield_paths. At the moment you can't use node tokens to rename your images / files.
Comment #6
Etroid CreditAttribution: Etroid commented+1 This would be a very useful feature.
Comment #7
arefen CreditAttribution: arefen commentedthis is very useful. please add this feature
Comment #8
MurzI have found workaround for insert node tokens in
paragraph_item
:entity_reference
field to your Paragraph bundle with machine namefield_node_reference
.field_node_reference
field.[paragraphs_item:field-node-reference:<node field>]
, here is some examples:[paragraphs_item:field-node-reference:title]
[paragraphs_item:field-node-reference:nid]
[paragraphs_item:field-node-reference:field_image]
Comment #9
delacosta456 CreditAttribution: delacosta456 commentedhi nice @Murz
But i am not sure this is going to help when in a case like the one mentioned by @Nchase where , you need to configure the url with token
Comment #10
Murz@delacosta456, token like
[paragraphs_item:field-node-reference:url]
must work well - can you try this?Comment #11
delacosta456 CreditAttribution: delacosta456 commented@ Murz
if i remember Prepopulating with ER Prepopulate Token ik ok for filling field in form..
The filefield_paths case is when configuring a file field on file settings page.
Comment #12
Murz@delacosta456, I test this case and all works well - I setup
[paragraphs_item:field-node-reference:nid].[file:ffp-extension-original]
in filefield file name settings, and try to upload image into paragraph item image field, and it successfully renamed to host node nid.But my example is not the solution for this issue, this is only workaround for this problem.
Good solution will be populate host node tokens in attached paragraphs items automatically by Paragraphs module.
Comment #13
delacosta456 CreditAttribution: delacosta456 commentedok.. i need your workaround but please help me understand some point of you scenario
2. Add entity_reference field to your Paragraph bundle with machine name field_node_reference.
the mchine name should it exactly be field_node_reference ?
3 . Create new Paragraphs item with this bundle, and select current host node in field_node_reference field.
Created the paragraph item mean that previously the paragraphs bundle created has been added as field to a node , right ?
Comment #14
MurzYou can use any field machine name, but after this you must use same name in token, so if you create feld_hostnode - you must use
[paragraphs_item:field-hostnode:url]
token.You must create new node with paragraphs field, and save it (because for node reference it must have nid). After this you add paragraph item to the node with you bundle type, and in this paragraph item you must find (via autocomplete) your current node.
After this tokens like
[paragraphs_item:field-node-reference:nid]
must work in paragraph body field like other tokens.Comment #15
delacosta456 CreditAttribution: delacosta456 commentedhi @Murz
Nice .. i reproduce your instruction and it is more clear...
But .. i just doest not why if i enable the prepopulate checkbox on the reference field added to paragraph bundle..,
and coming on the node that have this paragraph bundle, with argument present in url , the paragraph item reference fiedl is not prepopulated as expected
Comment #16
MurzYes, in all token list this field subitems is not pre-populated, but it works when I directly type those tokens.
Comment #17
delacosta456 CreditAttribution: delacosta456 commentedhi @Murz
Solved..
By doing this :
-Install https://www.drupal.org/project/paragraphs_defaults
- On the settings of Paragraph Default , for my paragraph bundle, i Edit Default add an empty paragraph and save so that the form should stay opened to be populated.
- Important, did a Batch Update (Link near to Edit Default)
and after that the field was correctly prepoulated
Comment #18
dedicated_hobby_coder CreditAttribution: dedicated_hobby_coder commentedIn case anyone needs the host node nid or its title "current-page" tokens are available.
Had to place a views field inside a paragraph sitting on a field collection inside a node... ... already dreaming up elaborate ideas of how to get that nid for my views argument when I remember to keep it simple stupid^^
[current-page:url:unaliased:args:value:1] and my view is just perfect^^
https://www.drupal.org/node/390482#token-current-page
maybe... expanding current-page tokens chain to something like [current-page:node:xxx:xxx] is the easier approach... field collections, paragraphs, bricks (?) ..., ..., same issue everywhere, how to get those fields and values by jumping up into the host...
it wouldn't eradicate the need to tokenize values on the paragraphs collections etc... but it would solve many issues in a single blow... and it allows unlimited nesting of entities inside entities
just an idea that the real programmers and developers can pick up for drupal 7.58 or 9 or so^^ ;)
Comment #19
NoComments CreditAttribution: NoComments commentedTo solve this problem, I created my own tokens in which I received the data I needed and used them.
like this
Comment #20
NoComments CreditAttribution: NoComments commentedTo solve this problem, I created my own tokens in which I received the data I needed and used them.
like this
Comment #21
mlncn CreditAttribution: mlncn at Agaric for Drutopia, National Institute for Children's Health Quality commentedShould there be a separate Drupal 8 issue? Should this issue be set to version 8.x (first)?
Comment #22
meyerrob CreditAttribution: meyerrob commentedThe complete code for a custom token module which replaces the host entity ID (like in [field_collection_item:host]) looks like this: