How to Create a Custom Content Type for Drupal 8 with Fields

How to Create a Custom Content Type for Drupal 8 with Fields

Introduction: Build a “RoloDex” App With Views Fields.

In this Tutorial, we will build a simple field-driven search application using Drupal 8 and a Custom Content type. Cards will be used to store information about people, companies, & other organizations with addresses, phone numbers, photos, etc.

How to Create a Custom Content Type for Drupal 8 with Fields

This Tutorial requires Views. Drupal 8 site developers can build custom page displays of card information with options for faceted search based on Fields for CRM purposes.

Step One:
Create the Custom Content Type: “Card”.

For our “RoloDex” App we are first going to create a custom Content Type named “Card” and then add fields for an image, address, phone number, email, & website. We will also add a main taxonomy to the Card to filter between people, businesses, & other organizations.

How to Create a Custom Content Type for Drupal 8 with Fields

Installation: Navigate to /admin/structure/types/add & create a new Content Type for Cards.

Description Text: “This card can be used to reference contact information for people, businesses, or other organizations.”

Settings: Don’t Promote to the Front Page, Don’t Create a New Revision, & Don’t Display Author & Published Information in the configuration check-boxes.

 Next: Save the Content Type & add a set of Taxonomy terms to the nodes.

Step Two:
Add Taxonomy Categories to the Card Fields.

First: Navigate to /admin/structure/taxonomy/add and add a new Taxonomy group for Cards.

How to Create a Custom Content Type for Drupal 8 with Fields

Settings: Within the “Card Terms” vocabulary, we want to create values for:

  • People
  • Businesses
  • Other Organizations

How to Create a Custom Content Type for Drupal 8 with Fields

Settings: Save each of the terms for use with Views in filtering the Card content into lists.

Next: Return to the Content Type settings for Cards at /admin/structure/types/manage/card/fields & add the Taxonomy filter.

How to Create a Custom Content Type for Drupal 8 with Fields

Settings: Create a Taxonomy Term Field and Label it “CardType”.

Configuration: Limit the values to one term per node & set the field to the “Card Terms”Taxonomy vocabulary.

Next: Navigate to /admin/structure/types/manage/card/form-display and “Select List” for Card Terms.

How to Create a Custom Content Type for Drupal 8 with Fields

This adds the ability to sort new Card posts by Taxonomy term on the content creation page:

How to Create a Custom Content Type for Drupal 8 with Fields

Complete: In the next steps, we will use these Taxonomy Terms on Card Nodes to filter dynamic content into lists using Views & implement Field Search capabilities.

Next: Let’s Add more information Fields to the Cards.

Step Three:
Add User/Company Information Fields to Cards.

In Step Three, we will add more user information Fields to the Card content type that can be used in display lists using Views and also made available to search.

Installation:

  1. Navigate to the Manage Fields page for Cards (/admin/structure/types/manage/card/fields)
  2. Add new Fields for: Image, Address, Phone Number, Email, & Website to the Card form.
  3. Remember to set new Thumbnail sizes for the Image at 220×220 px.

Image Settings: For the Image Field, we created a Reference Field with limit of 1 value set to Image and added it to the form. Then we navigated to /admin/config/media/image-styles to confirm the Image Thumbnail sizes.

How to Create a Custom Content Type for Drupal 8 with Fields

Address Fields: Go to Modules & enable the Telephone field module if it is not already enabled. Then, using a Field with a Text: Plain reference type, create fields for:

  • Address – Line 1
  • Address – Line 2
  • City
  • State
  • Zip Code
  • Country

Additional Fields:

  • Email (Email Field)
  • Phone (Telephone Field)
  • Website (Link Field)

The phone, email, & website Fields can all have link or phone/email specific reference values for browser processing. Arrange the order of the Fields on the Card node create page.

How to Create a Custom Content Type for Drupal 8 with Fields

Next: Navigate to the Card node create page & see your fields on the form.

Step Four:
Create New Content Using the Cards & Fields.

Start: Navigating to the /node/add/card page, you can see all of the Fields created for the Image, Taxonomy, & Address Information listed on the form in display order:

How to Create a Custom Content Type for Drupal 8 with Fields

Tip: Use this form to build your Rolodex content. Add business card information for customers & online contacts, or use as a database search tool for specialist development companies.

Settings: In the Manage Field Display section, change the display values to Inline for all of the text fields and set the image file to display with the 220px Thumbnail on node pages with the 220px Thumbnail on teaser views with a hidden label value.

Drupal 8 Results Pages – Card Content:

How to Create a Custom Content Type for Drupal 8 with Fields

Hint: Use custom CSS in a Drupal 8 Sub-Theme to change the default display values.

Next: Sort completed Cards into display lists with Exposed Search using Views.

Step Five:
Build Views for Card Display & Search.

To complete the project, we need to create search pages for the Taxonomy terms in Views and assign a URL address to them. We will expose the Views Search functions so that the Field terms such as address, city, state, country, etc. become filters for the content.

In this example, we removed the Street Address display for a more compact table view:

How to Create a Custom Content Type for Drupal 8 with Fields

Installation: Navigate to create a new view at: /admin/structure/views

  • Set the View to filter content of type Cards with Latest Posts Descending.
  • Set the Title to “Test Site – Search Database” with a URL of /card-search
  • Save & Edit the View. Then add the Fields to the display in a Table format.

How to Create a Custom Content Type for Drupal 8 with Fields

View Configuration: Drupal admins have the choice of displaying site Teasers or creating a custom display with the Fields using Tables & HTML Lists.

Exposed Search Settings: Create custom Views for each Taxonomy term & set the URLS to: /people, /businesses, & /organizations. You can then use these pages as site navigation elements with Exposed Search on the Field values.

Optional – Install the Facets Module: In order to build more advanced Faceted Search functionality into a Drupal 8 over what exposed Filters in Views offers by default, install the Facets module along with optional Range Widgets & REST Facets.

Tip: For better configuration on Address fields, install the Address module.

Conclusion: Indexed Card Search with Database Fields.

This tutorial allows Drupal 8 users to take advantage of the potential of using Fields on a custom Content Type with Views filters & Exposed Search. Site builders can use this tutorial to build a Rolodex app for a database that searches people, businesses, & other organizations.

Check out these top 3 Drupal hosting services:

Hostinger
AU$4.48 /mo
Starting price
Visit Hostinger
Rating based on expert review
  • User Friendly
    4.7
  • Support
    4.7
  • Features
    4.8
  • Reliability
    4.8
  • Pricing
    4.7
Kamatera
AU$6.00 /mo
Starting price
Visit Kamatera
Rating based on expert review
  • User Friendly
    3.5
  • Support
    3.0
  • Features
    3.9
  • Reliability
    4.0
  • Pricing
    4.3
Ultahost
AU$3.75 /mo
Starting price
Visit Ultahost
Rating based on expert review
  • User Friendly
    4.3
  • Support
    4.8
  • Features
    4.5
  • Reliability
    4.0
  • Pricing
    4.8

How to Manage Social Media Thumbnails in Drupal 8?

This Tutorial gives web publishers a step-by-step guide to social media thumbnai
less than a minute
Jeffrey Scott
Jeffrey Scott
Hosting Expert

How to Set Up a Custom Contact Form in Drupal 8

This Tutorial will show how to build a custom contact form to collect a user’s
less than a minute
Jeffrey Scott
Jeffrey Scott
Hosting Expert

How to Create an Image Gallery Using Views in Drupal 8?

This Tutorial will show how to create a tiled image gallery with support for res
less than a minute
Jeffrey Scott
Jeffrey Scott
Hosting Expert

How to Build Custom Forms in Drupal 8?

This Tutorial will show how to build custom Forms in Drupal 8 with Fields, Conte
less than a minute
Jeffrey Scott
Jeffrey Scott
Hosting Expert
HostAdvice.com provides professional web hosting reviews fully independent of any other entity. Our reviews are unbiased, honest, and apply the same evaluation standards to all those reviewed. While monetary compensation is received from a few of the companies listed on this site, compensation of services and products have no influence on the direction or conclusions of our reviews. Nor does the compensation influence our rankings for certain host companies. This compensation covers account purchasing costs, testing costs and royalties paid to reviewers.
Click to go to the top of the page
Go To Top