Drupal 8 – Defining and Creating Custom Content Types

d88

While you could publish all of this information in a Basic page or an Article, providing the features for sorting, filtering, making values required, calculating, and structuring how a content item is rendered on a page would be extremely difficult. Fortunately, Drupal’s ability to define custom content types makes all of the above possible, and provides many more features that you will find invaluable over time.

A custom content type is defined by you, the Drupal administrator, over and above the Basic page and Article content types. The ability to create custom content types is included in Drupal 8 core. To demonstrate the power and flexibility of custom content types, let’s create a new custom content type for capturing information about upcoming events. An event could be a concert, a play, a class, a game, or any other activity that is scheduled in advance. Custom content types are useful in responsive design.

When authoring information about an event, you may want to include the following details:

The name or title of the event
The date and time when the event begins
The date and time when the event ends
The venue or address where the event will be held
A description of the event
The price for attending the event

As you will see in a few moments, Drupal provides a simple-to-use administrator’s interface for creating and modifying custom content types. As soon as you define a custom content type, it is immediately available to those users who have the proper privileges to author, edit, publish, and delete that specific content type (Drupal provides the ability to restrict access to custom content types by user role).

Creating a custom content type takes two basic steps: sitting down and listing the types of information you want to collect, and building the custom content type using Drupal’s custom content type administration screens.

For this example, let’s create a custom content type for an event that includes the types of information listed in the previous section. To get started, click the Manage link at the top of the page and the Structure link in the submenu. On the Structure page click “Content types.”

To begin the process, do the following:

Fill in the name of the content type, which in our case is “Event.” The text below the Name field provides a set of guidelines that you should follow when creating a name for a new content type.
Provide a description of how this content type should be used, such as “A content
Type used to capture the details about upcoming events.”
Change the “Title field label” from just Title to “Event Title,” making it more descriptive and intuitive to the author who will be using this template for authoring event information.
Leave the “Preview before submitting” setting as Optional.
Provide a brief explanation of the submission guidelines for this content type. This is an optional value, and may not apply to your content type. For our Event content type, we will use “Please fill out all required fields before submitting the event” as the submission guidelines. You can choose to use or ignore this field when creating new content types.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s