Reusing Existing Fields

After you create a CCK field, it is available to any other content type in your Drupal environment. As you have seen, it can have global settings (for all content types in which it might occur) and content-type-sensitive settings (such as the path and default title or ALT text). For this reason, it makes sense to check to see if a field already exists that can be reused. After you have one or more CCK fields created in your Drupal environment, the bottom of the Add Fields page has a section for adding an existing field, as Figure 7.13 shows.


Reuse existing fields where appropriate.

« ^ o


| Jesse Feller / North Country Consulting

My account My bookmarks

Feed aggregator

G Add Fields and group You can add a field to a


to the content type, and arrange them on content display group by dragging it below and to the right of the group.



Node moduli; form

Content management

+ Menu settings

Menu module form.

Comments Content

Node module form.


4. Book

Book module form.

Content types

File attachments

Upload module form

Date Tools

Feed aggregator



4. © New field

Post settings

field_ 1 - Selects field type

M - Select a widget - :

RSS publishing

Field name (a-z, 0-9, J © Type of data to stor

Form element to edit the data.


4. © Existing field

Site building

V - Select an existing field - )

fr-Select« whig«—fH

Site configuration


^jLmaiaiatt^fflll I'ihM^

Form element to edit the data.

Module Uploader Panels

O New group

File: field JmagecachMliiiage)


Store administration


Croup name (a-i, 0-9, J

Ttieme Uploader

User management Reports


Advanced help

Example help

It is a good idea to reuse a field that has the same type of data element in it. The example shown in Figure 7.13 has three CCK fields that have been added to the Drupal environment, and it demonstrates how to make the most of field reusability.

Notice that, in the pop-up menu, you see the underlying data type (File or Date in these cases) and the field name that has been created. In parentheses, you see the default label for the field.

To make your fields reusable, make all these values as clear and specific as possible. In this case, a field based on the date type that is called Start Date is clearly just that. An image field called Image may be an absolutely generic image, but even that specificity might be made clearer if its default label is Generic Image and if the underlying field is called field_generic_image.

Was this article helpful?

+1 0

Post a comment