Use date operations on a computed field filter in a view
Posted
by stephenhay
on Stack Overflow
See other posts from Stack Overflow
or by stephenhay
Published on 2010-05-25T09:34:07Z
Indexed on
2010/05/25
9:41 UTC
Read the original article
Hit count: 260
drupal
|computed-field
I'd like to expose a filter in Views based on a Computed Field. This field should utilize the date operation "less than". Apparently, a date type is not available to computed field (varchar is). However, using varchar results in views treating the field as a string rather than as a date, without the operation I'm looking for.
So I tried using a timestamp instead of a date, which allowed me to use an integer data type. The exposed view gives me a "less than" operation, but as it's still not a date, the user must type in a timestamp. Not handy.
So I'm thinking the best way to do this is to create a new (hidden) CCK field which is a date field, and set the value of this field to the value of the Computed Field. I can then use the new CCK field for my exposed filter.
But I'm not getting anywhere with this, as I'm unsure how to set another CCK field with a Computed Field. To return the value to the computed field itself, I'm using the standard:
$node_field[0]['value'] = $newestdate;
I would like to set the value of the new CCK field to $newestdate
as well. Can anyone help?
© Stack Overflow or respective owner