DRAFT: Body and Teaser are now separate fields
Last modified: August 21, 2009 - 22:41
This page is a DRAFT text for inclusion in http://drupal.org/node/224333 when complete. It will be unpublished once it has been reviewed and incorporated into the main handbook page.
Node Body and Teaser Changes
In Drupal 7 the node body becomes a field in core. This means the body field has changed from a specially handled node field to a field handled with the Field API.
This change results in the following:
- The body field is a field in core of type: Long text and summary (text_with_summary)
- The
$node->teaserfield no longer exists - The
$node->bodyfield still exists but no longer represents the full content of the node, it is now a display-only field containing only the body field contents. Additionally, its data-type changes from text to array. Changes made to this field will not be rendered so it is recommended developers simply ignore it. - The body field should be viewed and/or changed in
$node->content['body']using Field API best practice - The default node data entry form has both Summary and Full text form fields
- The JavaScript splitter is no longer used on the node data entry form (If you want to recreate this behavior an example can be found in the Drupal 6 Node Comment module)
- The data entry form processing rules for the Summary and Full text form fields are:
- If Summary text exists, it is used for the Teaser view
- If no Summary text exists, a trimmed version of Full text is used
- The length of the trimmed version is set in the node's display settings
- The length of the Full text trimmed version can be manually set with <!--break-->
If your module changes user-facing behavior on node data entry forms familiarize yourself with the Field API widgets and formatters.
The following functions have been removed:
node_prepare().$node->bodyand$node->teaserno longer need special preparation.node_body_field(). The form element 'body' is now generated by Field APInode_teaser()has been renamed totext_summary(). The function now runshtmlcorrectorif applicable.
