I'm using computed field to generate a field used in the auto node title. I have to edit the node twice to get the correct title to show up.

1. Is there any way to get the computed field to "compute" a couple of times so the data is there?
2. Is there a way to get the computed field to "compute" before the auto node title?

Comments

asb’s picture

How do you get the computed field's value into the node title? In my setup, computed field does not expose it's values as token, so there's no replacement pattern I could enter for automatic title generation.

Thanks & greetings,
-asb

clarkburbidge’s picture

All my cck fields are available as tokens. I don't know what I did to get it that way. I thought that was standard.

Moonshine’s picture

While this response may be too late for you, I think your problem may be related to this:

#414088: Computed fields should compute on $op='presave' and/or $op='validate'

while I'll be looking into here...

clarkburbidge’s picture

This is still and issue for me. I'm not sure if 'presave" would fix the issue. Currently I have a views bulk operation that I run occasionally to band aid the issue. I'd love to see it fixed, but I think it is more the way I have it set up with a nested computed CCK fields as one of the tokens for my auto node title. Thanks for info and I'll be following the results!

csc4’s picture

I'm sure you're right - the computation has to happen before the value is tokenised or the value can't be available.

I'd been thinking it was simply an issue with module weights?

I've been struggling with the same problem. Is it as simple as patching the module to change the operation to presave or are there other considerations?

TripleEmcoder’s picture

Subscribing.

KerriO’s picture

Subscribing

millenniumtree’s picture

Aghghh! Yes!

brycesenz’s picture

Subscribing.

Anonymous’s picture

Subscribe

Moonshine’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

texas-bronius’s picture

Version: 6.x-1.0-beta2 » 7.x-1.x-dev

For anyone stumbling across this.. I found a win in passing a value in the $node (auto_nodetitle) and $entity (computed_field) objects like:

Auto Node Title config on content type using PHP eval:

$field = $node->field_card_cardid[$node->language];
$node->c4c_cardid = (is_array($field) && isset($field[0])) ? $field[0]['value'] : _c4c_generate_cardid();
return "Card No: " . $node->c4c_cardid;

(include php tags)

Computed Field config:

// $entity object is assigned ->c4c_cardid property in auto_nodetitle php snippet on this content type
$entity_field[0]['value'] = $entity->c4c_cardid;

(omit php tags)

Bonus tucked in, so here's what all is going on:

  1. Create Node Title (provided by auto_nodetitle) based on an external function. Only calculate it if this value has not already been calculated (ie. Node Create).
  2. Store the important part to store in an entity field directly on the $node object (assumed passed by reference). This doesn't get saved to db, only makes it available to other node operations down the road.
  3. Computed field (provided by computed_field module) simply looks for and uses the temporary property on its $entity ($node) object in scope.

The added bonus here is that my computed field does *not* update with each node save (desired behavior in my use case). The overall take-away here is that auto_nodetitle has access to and can modify $node and fires before computed_field which has access to and can modify $entity. Note: You can always debug with dsm($node) and dsm($entity) in the respective eval blocks with the devel module.

Appears to work for me thus far... hth