0

I have node 1 has a reference to node 2 & node 3 how can I make node 2 & node 3 have a reference automatically (because they have the same reference with node1)?

1
  • Did you try the Rules module?
    – Ismini
    Commented Jun 21, 2017 at 8:36

2 Answers 2

1

You can implement hook_entity_insert()

Act on entities when inserted.

Parameters

$entity: The entity object.

$type: The type of entity being inserted (i.e. node, user, comment).

and inside the hook check if you have more than one node in the reference field, in this case you will edit all the nodes and add the reference to the others.

3
  • Thank you so much !! but I'm not sure how can I do that ? i'm new to The hooks & that stuff??
    – MohK
    Commented Jun 21, 2017 at 20:05
  • @MohK Well, you will need to write a little module to do this. Commented Jun 21, 2017 at 20:17
  • @MohK finally do you solve your problem? Commented Sep 7, 2017 at 17:01
0

You can find a solution that works for me on the following pages: https://www.drupal.org/project/prepopulate/issues/2668010 it is using the module prepopulate and you can find the documentation on this module page.

An other solution is proposed by using the business rule module.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.