This module seems like it's a duplicate module to the Computed Field.....

CommentFileSizeAuthor
#11 dynamic-vs-computed.png31.66 KBPedro Lozano

Comments

sourcen’s picture

Status: Active » Closed (works as designed)

ComputedField computes the value while the node is added and saves in the DB but this module doesn't save any info in DB... values are computed whenever the node is rendered in the frontend

owen barton’s picture

Status: Closed (works as designed) » Active

Sorry, I am pretty sure this is actually duplicate - Computed Field can store the result in the database, but you can also tell it to not do this and instead recompute it on each view using the checkbox on the field configuration form:

From http://drupal.org/node/149225:

Store using the database settings below
If this is checked then the field is computed on node save and stored. If it isn't stored then it will be recomputed every time you view a node containing this field.

andyhu’s picture

I think the current computed_field module doesn't work well with CCK 6.x-2.1. In the current version of CCK, the hook of hook_field with op = 'load' will not be invoked each time you view the node by default if the node is cached. It should use 'sanitize' as op for dynamic fields. Anyway, computed field doesn't work with Views if you don't want to store the computed value to database. If you can get this module working with Views, it would be quite useful!

robloach’s picture

Instead of saying something is broken, and then making an entirely whole new module for it, it's usually better to help fix the thing that's broken.

Computed Field doesn't show values in Views if you don't store them in the database because if you did display them, it would be a huge performance hit. Storing the values in the database gives you speed.

dpearcefl’s picture

Just a comment:

There are good reasons for this module to continue. I needed a field to be calculated when viewed to give me a date corresponding to "the first Thursday of March in the current year". Storing the date will not work for me if the field does not get recalculated but once.

Keep up the good work.

aren cambre’s picture

Title: Duplicate Module? » Merge with Computed Field
Issue tags: +duplicate module

Making the title more direct.

pepe roni’s picture

I also found out that computed field currently does not work as desired, as computed values get not recalculated on node view but only on node save, even if the values are not stored in the database. So when I found this module I thought it could solve my problems. If you look into the usage statistics you will see there is really a need for this functionality. And after thinking about its target to solve the problem, I also think, it indeed is a duplicate of computed field, because it does something, computed field should do (or users think it should do).

So, please help the maintainers of computed field to solve the problem instead of creating a new module.

BTW. I downloaded the module with drush dl computedfield and then tried to enable the module with drush enable computedfield but the latter command failed. I looked into the module and saw that is was named phptext inside! What the hell does phptext have to do with dynamic field?

Drush? Check this: http://drupal.org/project/drush

joelstein’s picture

Title: Merge with Computed Field » Merge with Computed Field or Views Custom Field

FYI, there is yet another module which accomplished this main objective of this module: Views Custom Field.

vacilando’s picture

So far I am forced to use Dynamic Field because Computed Field indeed does not re-calculate values except on save (see this issue: http://drupal.org/node/598582). Subscribing.

roball’s picture

Title: Merge with Computed Field or Views Custom Field » Merge with Computed Field
Category: bug » feature

The "Views Custom Field" module is entirely different from "Computed Field" because it does *not* provide a new CCK field type, so it cannot be used to add custom fields to nodes. It can only be used to add custom View fields to be displayed in Views.

Pedro Lozano’s picture

StatusFileSize
new31.66 KB

Here is a demo.

Code for dynamic field (PHP Code):

return format_date(time(), 'custom', 'r');

Code for computed field ("Display format"):

$display = format_date(time(), 'custom', 'r');

Computed field configured not to store the values in database.

Results in the attached image. Both fields al always recalculated correctly with the same results.

NO, you don't have to edit the node for the computed field to be recalculated.

It's just the views integration what does not work on Computed. A simple patch should have solved it.

jfine’s picture

It's my understanding computed field can't access $node in "Display format". I'm trying to add a computed field for a simple widget that pulls in some info based on node id ($node->nid). This functionality is the fundamental difference (and in my opinion a failure) between computed field and others. Although computed field would work, touching or re-saving all my content just won't work.

Pedro Lozano’s picture

It's my understanding computed field can't access $node in "Display format".

Actually it can. It's just in $element['#node'].

The cvs version already can access $node directly.

jfine’s picture

Ah, cool. Guess very shortly dynamic field will be obsoleted by computed field then.

roball’s picture

Hm, accessing $node as Display code did not work for me (using the latest dev version). Did you succeed, Pedro?