Hi,
I want to achieve the following: When a user flags a node I want all nodes with the same term from a specific vocabulary to be flagged with another flag. Background: it is a simple booking system for events (which are created as nodes). Events going on at the same time will get the same term of vocabulary "time period", for example "Saturday morning". So if a event on "Saturday morning" is booked the other events should be marked as "blocked" automatically so that they are filtered out from the event choosing list.
I created a rule which is triggered by "Node has been flagged under 'Event booked'". It has the action "Load term" which is working fine. Now I ask myself how I get this term into the VBO. The VBO views is created on node base and with the argument "Term Id" and the needed filters. Is that the way to do it??? What do I have to define in arguments field when defining the VBO programatically action in rules to pass through the term id?????
Thank you very much in advance for your support.
Greez,
Tobias
Comments
Comment #1
infojunkieThe VBO would accept an argument "Taxonomy Term: Tid" that it uses to include nodes of the same period.
Maybe you will want to add another "Node: Nid" argument that is excluded from the query - to which you pass the original node id.
To pass these arguments from the rule to VBO, you enter the following code in the rule's VBO action setting page, section View arguments:
assuming the loaded term is named "term" and the content is named "node".
Comment #2
infojunkieYou will probably need the latest dev because a lot of Rules-related fixes went in since 1.10.
Comment #3
tobiberlinHi infojunkie,
thank you very much for your prompt response. I tried it but it did not work for me. Everything works fine if no argument is set in VBO views: For example I filtered the view just listing all events. When I flag an event the VBO is run and all events are flagged right as "blocked". But what is not working is the argument thing: When I try to pass through an argument in the way you described it does not work. Depending on argument settings in VBO all events are flagged as "blocked" again or no one. I tested the VBO with the preview in views administration UI and found out that everything works just fine when I put in the term ID as an argument.
I also tested it using just the node ID - nothing changes, it seems as if the argument is not passed through.
I also checked if $term->tid and $node->nid have the right values by finishing the rule with an action "Show message on page" where I used custom PHP code to print these variables. The values are set right and I wrote the arguments in the VBO rules action as you described, so there is also no mistake in writing...
Do you have any idea what can cause this failure in argument passing?
Greez,
Tobias
Comment #4
tobiberlinAh PS: I installed the latest dev-version as well!
Comment #5
tobiberlinSeems to be related to this issue: http://drupal.org/node/979852 ?!
Comment #6
infojunkieThe other issue is related to operation arguments. This one is related to view arguments if I understand correctly.
Comment #7
tobiberlinOk... maybe... but still I do not know why the arguments defined in the arguments box in the rule action for VBO are not passed through to the view?! :-(
Comment #8
infojunkieSure, I'm working on that.
Comment #9
tobiberlinOk... did not want to annoy you, sorry for that. It is just that this could boost my project enormously and could become a vital part of my solution. It could save me from having to develop a module for some of my issues with that project. Therefore I would be really very grateful if you could give me an estimation - what do you think: Is this issue complex and will take much time to be solved or might you find a solution for that soon? If I had the knowledge I would support you but as I am not a programmer I depend on your work...
Thank you very much in advance!
Tobias
Comment #10
infojunkieI wasn't able to reproduce this locally. You have two options:
1. Export the view and copy it here for me to examine it
2. Show me your development environment where I can see this problem
Comment #11
tobiberlinAs I develop this project currently on my PC I firstly copy the view... if this brings no result I would be very thankful if you could have a look on the development project. For this I would upload it to my server and give you the admin access.
Comment #12
that0n3guy commentedAre you sure you have the operation you are using enabled in the view? (see this: http://drupal.org/node/987440)
Views arguments work for me (I didnt test your exact case).
Comment #13
tobiberlinYes, I am sure... the action is performed with no filtering on the view result. Just the filtering by an argument does not work... maybe it is helpful to have a look on the rule?!
Comment #14
tobiberlinchanged title
Comment #15
infojunkieI found the problem:
The VBO action cannot access the
$term2variable that was loaded by Rules. Therefore, the view argument is always empty.To solve this, replace your views argument with:
Let me know how that works for you.
Adding support for Rules variables is a feature request for VBO that I will work on soon.
Comment #16
tobiberlinHi infojunkie,
I changed the argument settings as you suggested but nothing changed - still all nodes filtered by the views are changed by the action. The argument setting has no influence.
Best,
Tobias
Comment #17
infojunkieYes, very sorry about that: there was a typo in the code I pasted. The correct code is:
Comment #18
tobiberlincool, this works... but isn't it unsure that the term in question will always have the key 0 in the array $terms???? I mean if there are defined many vocabularies with many terms how can I make sure that just the one term of a specific vocabulary is given through to the VBO?
I do not know much about PHP but for me it looks as if the term is taken from the node - it is not the one that I loaded... am I right????
Comment #19
infojunkieThe term that you load is the first one, as defined by the token. This code does exactly the same.
Comment #20
tobiberlincool... thank you
Comment #21
infojunkie