Computed Field

Moonshine - July 21, 2006 - 01:22

Maintainers

Computed Field is being maintained by Agileware, http://www.agileware.net (Drupal 5 branch) and Moonshine (Drupal 6 branch). CVS HEAD is currently for Drupal 6!

If you would also like to help maintain this module then please contact Moonshine or Agileware.

About Computed Field

Computed Field is a very powerful CCK field module that lets you add a custom "computed fields" to your content types. These computed fields are populated with values that you define via PHP code. You may draw on anything available to Drupal, including other fields, the current user, database tables, you name it. (Feeling the power yet? :) ) You can also choose whether to store your computed field values in the database with other content fields, or have them "calculated" on the fly during node views. (Although you should note that Views use requires database stored values.) This field is literally the Swiss Army knife of CCK fields. So start cooking up your PHP based values!

Computed Field requires the content module (CCK) and working knowledge of PHP.

Updates

  • As of 2006-9-12 The computed code and display format are field settings, not widget settings. This means if you add a computed field to more than one content type then they will share the same code. Updating shouldn't be a problem because the module will fall back to using a computed field's widget's code if its field's code hasn't been set.
  • As of 2006-8-11 the 'display format' setting has changed. You'll need to update any existing computed fields: If your display format was This is the value: %value, then change it to $display = 'This is the value: ' . $node_field_item['value'];

Usage

Getting Started

Before you can use Computed Field, you'll need to get CCK and enable (at the very least) the 'content' module. You will probably also want to enable the other CCK modules, such as 'text', 'number', 'date', etc.

To add a computed field to a content type, go to administer > content > content types, select the content type you want to add to, and click on the 'add field' tab. One of the field types available should be 'Computed', and it should have one bullet point under it, also labelled 'Computed'. If you select this, give your field a name, and submit the form, you will get to the configuration page for your new computed field.

Configuration and examples

Configuration of this module has been relocated to a page of the CCK manual on drupal.org.
http://drupal.org/node/126522

If you have another useful (or instructive) example please add it to the manual pages.

Releases

Official releasesDateSizeLinksStatus
5.x-1.22007-May-1510.72 KBRecommended for 5.xThis is currently the recommended release for 5.x.
Development snapshotsDateSizeLinksStatus
6.x-1.x-dev2008-Aug-2611.2 KBDevelopment snapshotDevelopment snapshots are automatically regenerated and their contents can frequently change, so they are not recommended for production use.
 
 

Drupal is a registered trademark of Dries Buytaert.