2

I'm currently stuck in the creation of a custom rule.

I would like to show a button on some content type, this button called a list of other content called "guide". I list these contents (guide) in a view and I added a field to associate a rule vbo. In the type of content I have a guide entity reference fields might add my id of the current node content (the button add to the guide) to guide one or more listed.

How to perform the action:

  1. get the nid of current content
  2. define the fields at the end of the reference entity or selected guides
  3. save the guide(s)

Note : The list of guides is showed in a lightbox when button "add to guide" in a content was clicked.

Thank you very much in advance

1

I will first confirm if I understood this correctly.

  • You have a content type where you will show a button. Let's call this content type MainType.
  • You have another content type called guide.
  • You have an entity reference field on guide which points to a particular node (nid) of content type MainType.
  • In nodes of MainType, there is a button which shows all guides pointing to the visible node. You already have this view.
  • You want to add a link which will create a new guide node with entity reference pointing the node on which the link was clicked.
  • From your comment: You want to use VBO to set referenced field in selected guide nodes to the current node.

I can't think of a way to do this without code, as the context of the original node is probably lost in the view of guide nodes. However, you can do it in a slightly different way:

Create a Rules component with two variables, both of Node type. First one is your guide node, set by VBO and the second will be your reference to the node.

You should then write your rules actions to set entity field value for guide node's field to the nid of second reference. You can take a look at this video which implements a very similar requirement.

I hope this helps.

  • Thanks for your response hw, Your above is true (sorry for my first post, I'm myself a little confused). Just the last point is not exactly correct, i don't want to create a new guide, i just want to populate a field in one (or more) existing guides. For this i use VBO (View Bulk Operation) for mass operations. In this case, with using VBO, you always think i can realized this action without rules ? I just want to get the nid of currently MainType, and to select one or multiple guides (by view called by clicked button) and set this current nid to guide's entity ref fields – Alexis Jun 10 '13 at 15:30
  • Ok, VBO and Rules are necessary to do this, however, you will need to write code to make it work exactly like you describe. However, if you are open to a little change, you can use Rules components to set Entity field values from a parameter. – hw. Jun 10 '13 at 16:30
  • But, my problem is where I do not know how to perform this action with rules / components.. What do you mean little change? – Alexis Jun 10 '13 at 19:14
  • Oops sorry for my last comment, I had not seen the change of your post, I test it and come back for the verdict, thank you – Alexis Jun 11 '13 at 7:43
  • I do not understand why, I'm sure I followed the video that you sent me, when set a data value in my action (component type rule), so I selected as the value to be changed: node: my_entity_ref_field and then when I want to use as the new value to be passed: Nid_to_guide (my integer variable) I have no access .. Same when I try the same operation by "add a list of data". This module will make me crazy.. – Alexis Jun 11 '13 at 8:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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