Hi there,

First of all, thanks for a beautiful module - although I have a (hopefully) small issue.
I have a Computed Field called "compufield", and I store its value, varchar, length 50. When I write this (admittedly, rather silly) code in the "Computed Code" area, everything works:

$tostore = $node->nid + 10000;
$node_field[0]['value'] = $tostore;

Since compufield is set to display, I see its value in node view, after editing, of course - it would be nice to activate Computed Fields on node view, not only on node edit. Anyway, "Computed Field" works.

However, I also have a cck field called "cckyear". This contains values like "Year 12, issue 3, March". I would like to take out the string "Year 12", with this code:

$temparray = explode(',', $node->field_cckyear[0]['view']);
$node_field[0]['value'] = $temparray[0];

I edit my node, and I save. For some reason, this value is not stored or displayed. A var_dump of $node shows the field is present, but the contents is NULL. The code itself is correct: when I "explode" and then echo $temparray[0] in node_mycontenttype.tpl.php, it shows "Year 12", as it is expected to do. So, why doesn't it show up in compufield? And how can I make it work?

Obviously, the code used in this example is trivial, but I only used it to verify if it would work. Hopefully someone can point me in the right direction??

Thanks,

Ludo

Comments

bdragon’s picture

If I were to take a guess, it would be that $node->field_cckyear[0]['view'] is NOT set at the time computed_field runs.

The 'view' key is a *display* key, so it probabaly doesn't exist during node saving.

You should probabaly render / check_plain / whatever the 'value' key yourself instead.

bdragon’s picture

Status: Active » Closed (fixed)

Closing, assuming fixed.