Dynamic Field

sourcen - February 10, 2009 - 10:22

Dynamic Field is a CCK field that returns a textarea where you can enter custom PHP code. The code is computed real-time and lets you access Drupal objects like $node, $user...

Note:
This is not a duplicate of ComputedField! ComputedField computes and saves the value in the database when the node is created but Dynamic Field doesn't store the computed value...it computes the php whenever the node is rendered in the theme.

Usage:
All you need to do is place the PHP directly into the CCK field without the <? ?> tag.

Below is an example to return the Node ID:

        $nid = $node->nid;
        return $nid;

Another example to return the Content Type:

        $ntype = $node->type;
        return $ntype;

Downloads

Version Downloads Date Links
6.x-1.0 Download (6.86 KB) 2009-Feb-10 Notes


 
 

Drupal is a registered trademark of Dries Buytaert.