Hi,

according to Fago, the Computed Field module should provide a token. In my setup, it simply does not.

Computed Code:

if (!empty($node_field[0]['value'])) {  // the node is not new
  return $node_field[0]['value'];
}
else {  // the node is new
  $count = db_result(db_query("SELECT COUNT(*) from node WHERE type = 'mediathek'"));
  $node_field[0]['value'] = $count;
}

Token is supposed to be available for automatic title generation through Automatic node titles.

Thanks & greetings, -asb

CommentFileSizeAuthor
#1 explainfield_token_support.patch777 bytesshawn dearmond

Comments

shawn dearmond’s picture

Status: Active » Needs review
StatusFileSize
new777 bytes

Here's a patch that works for me. See if it works for you.

I have only tried it using workflow_ng.

Oops, wrong place. Sorry, this was supposed to go to the explainfield module issue.

Shawn

shawn dearmond’s picture

Status: Needs review » Closed (duplicate)

This is a duplicate issue, anyway, and a patch is available:

#243775: Token support for computed field

asb’s picture

Thanks for the pointer. The patch applies cleanly, but it only solves the problem halfway: When saving once, the computed field's value isn't entered; after erasing the node's title and saving the node a second time, it is entered properly. For whatever reason, Pathauto doesn't have this problem, there the token is evaluated correctly.

Greetings, -asb