Content types

Martians

Say you run a dating site for martians. Hey, they need dating sites, too.

Let’s make a content type for storing data about martians. Then we’ll add some fields.

What we want to know

Here’s what we want to know about each martian.

  • Name, like Xrtwye33
  • Birth date
  • Gender – martians have three: female, male, and tamale. Like humans, each martian can have only one gender at a time.
  • Limbs, how many.

References

Fields have types, like List (text), Date, and Number (integer). There are some important types we haven’t talked about: references. References are fields that refer to other nodes.

BFF text field

Each sloth has a BFF. Just one BFF. They’re prickly about that. One and only one BFF.

Say you wanted to store that info.

Fields and data types

The Sloth content type in the previous lesson had fields for name, weight, and birth date. The fields hold different types of data. Names are text. Weights are numbers. Birth dates are, well, dates.

Drupal has lots of field types, to store whatever data you need. Modules add even more, like map coordinates. In this lesson, we’ll look at some of the most common field types.

Field types

When you create a new field, you get to select the field type:

Field types

Drupal core gives you 23 field types.

Content types

Earlier, the team decided that the IS needs three custom content types:

  • Person
  • Project
  • Event

Person

The team listed these fields:

  • Name
  • Phone (manager access only)
  • Email (manager access only)
  • Dues paid? (manager access only)
  • Affiliation (member, etc.) (manager access only)
  • Major
  • Projects
  • Notes (manager access only)

Each Person node has to have a title field. We’ll use that for Name, by giving the title field the label Name.