I added a cck field to content profile named field_scores, and want to use rule module to do sth. to update this field +1.

I tried to use 'populate a field', but I don't know how to write the php code to specify the field value.

return array ( 0 => array ('value' => '???') );

any help??
thanks.

Comments

Mark Theunissen’s picture

Not sure about the Rules module, but try http://drupal.org/project/computed_field

bowenzbiz’s picture

Thanks, Mark.

I had considered about the computed_field module, but it cann't fulfill my requirement.

Because I did not store all the history in the database, and they will be purged sometimes.

I just need a trigger to add 1 to original value.

WorldFallz’s picture

Try:

return array(
  0 => array('value' => $node->field_scores[0]['value'] + 1),
);
bowenzbiz’s picture

Thanks. WorldFallz

But it still doesn't work.

WorldFallz’s picture

"it doesn't work" doesn't tell me anything. I tested it, and it works on my dev system with a cck integer field named "field_scores".

bowenzbiz’s picture

Thank you for your help.

Solved.

I use token code below.

return array(
  0 => array('value' => [profile_node:field_scores-formatted] + 1),
);

Unfortunately. $node->field_scores[0]['value'] still doesn't work.

It seems that $node->field_scores[0]['value'] === 0. $node is not recognized.

Anyway, thank you very much.

WorldFallz’s picture

odd-- I have full access to $node in my rule. Oh well, as long as it works.

happy to help ;-)