Hi,
I've created a button link to create a meeting entity directly on student profile page. It will take node id from current student page to add it to prepopulate modüle link automatically.
<a href="https://example.com/node/add/meeting?edit[field_student][widget][0][target_id]=[current-page:node:nid] "target="_blank">New Meeting</a>
I'm trying to get student node ID. I can get current page node:id with token(patch is working) on other part of website. But I couldn't get with prepopulate module.
How can I get node ID instead of manual adding on url. Is it possible to use with prepopulate module or Do I have to do something else?
Thanks
Comments
Comment #2
simplified-computing commentedsame thing here, did you get a solution?
Comment #3
toprak commentedUnfortunately, no.
You may consider to use Field Clone with eva module as an alternative.
Comment #4
scottsawyerI am not sure in what context you are creating this link, so I'll assume it's either something you are either generating yourself or it's something coming from a field.
In case it's just a link field, you should be able to specify the token as part of the default value using something like https://www.drupal.org/project/field_default_token.
In case it's something you are generating in either twig or a preprocess function, you could do something like:
Then in your Twig, you could do something like:
UPDATE:
Duh, forgot, you can also use a Markup Field with the patch in this thread.
Comment #5
simplified-computing commentedcontent type: student
content type: meeting, with reference field "field_student"
meetings is a view (block) on student node with contextual filter: field "field_student", provide default value, content id from url
to create a new meeting node with prepopulate
1. add a view display to meetings view (type attachment)
2. change filter to: Content: Content type (= Student)
2. add a field: Content: ID [hidden]
3. add a field: Global: Custom text
<a href="/node/add/meeting?edit[field_student][widget][0][target_id]={{ nid }}">New Meeting</a>5. set "Inherit contextual filters: No"
4. replace the contextual filter "field_student" with "Content: ID" for the attached view display
5. attach to: Block
Comment #6
toprak commentedI gave up two months ago, but I decided to try again.
Thank you @simplified-computing. Your way is easier for me. It Works.
Also, thank you @scottsawyer for help .