Posted by joecanti on June 1, 2010 at 10:20pm
Hi all,
Please could someone help me - I am trying to insert a bit of custom php into an action so that when triggered, 1 is added to a CCK numerical field.
Below is a jpeg of where I've got to so far - the problem is it keeps refreshing the CCK field with the number and not adding it on:
(In the example I was trying to add 5)
http://avocet-designs.co.uk/populate_rules.jpg
The content type is called 'track' and the field is called 'plusvote'.
The idea is that when a Flag is activated on a 'track', a rule is triggered and a vote (+1) is added to the CCK 'plusvote' field
Should be fairly simple but I just cant get it to function...
Any help much appreciated,
cheers, Joe
Comments
Try the Rules module
It is much more powerful than actions/triggers and allows custom PHP and setting CCK fields easily.
Thomas Hansen
www.ThomasHansen.me
Your rule seems fine...
Have you checked that it is actually executed? Turning on the messages at rules -> settings has helped me many times...
//Johan Falk, NodeOne, Sweden
Thanks for the reply and the
Thanks for the reply and the tip...
This is what it spits out:
It looks like it works well, but it's like it wipes the field then replaces it with the + value rather than taking the initial field value and adding to it...?
Maybe I'm using the wrong type of rule? Many thanks, Joe
One node too many?
In the debug information it seems that you are loading the flagged node manually. This shouldn't be necessary -- it is already loaded -- and could cause some confusion when two identical nodes are saved. (I imagine that the copy that you haven't changed might be saved last, thereby wiping out any changes you made...)
Check if there isn't already a node object available, probably under the name flagged node. If so, run your 'populate CCK field' action on that node instead.
Good luck!
//Johan Falk, NodeOne, Sweden
hey can you post how you did
hey can you post how you did this, i am kinda trying to the same through rules and cck, only issue i am having is +1 ing the value of the given cck field,