In this video, you’ll learn how to create a content type in Drupal.
We’ll cover the following:
- Create a “Product” content type
- Configure content type default options
- Access the Product content form
We’ve looked at how to create content and how the entity and field system works. Now it’s time to do some actual site building. Let’s imagine we want to display some type of products in a Drupal site. So let’s start things off by creating a content type called product. We’ll start by going to structure, content types and then click on add content type, then add product into the name field. This is what the content type will be called. Then in description, enter in a description for the content type. I’ll enter in used for selling products. And then below description, we can configure the content type. And from the submission form settings, you can change the label of the title field. Remember the title field is hard-coded, we can’t delete the field, you can hide it, but from here, you can change the label of the title field.
And then below that we have the preview before submitting options. This allows you to control if previews are fully disabled, if they are optional, or if they are required. I always personally like to disable previews, because they cause more trouble than they are worth, so let’s select disabled. Then below that, we have explanation or submission guidelines. Any text entered into this field will appear on the product content form. I have personally never used this feature, but it’s there if you need it.
And then below submission form settings, we have publishing options. From here, you can configure the default publishing options. If published is checked, this will set the page to be published by default. When a user is on the content form, the published check box will be checked by default. Then we have the promoted to front page option. This will show the page on the front page or home page. This option will only work if you are using the default front page listing, but it’s useful if you want to flag content to appear on the front page. But for this content type, I’ll uncheck it.
Then we have the sticky at top of lists option. It’s similar to the promoted to front page, it only works if you are using the default front page listing. This option will sort any content to the top of the list, which has been flagged as sticky, to the top of list. And finally, we have create new revision. This option will create a new revision when content is updated. I always leave this option on. So make sure you have published and create new revision checked.
Then below publishing options, we have display settings. You can configure the content type to display the author and date information, when viewing a product. But for this content type, let’s go ahead and uncheck it. And then below display settings, we have menu settings. This option allows you to add content directly to a menu from the content form. To show you what this looks like, let’s go to content, and I will open that up in a new tab, and then go to add content, basic page and then click on menu settings on the right hand side, and then click on provide a menu link. This option allows you to add basic pages to the main navigation directly from the content form. Now for our product content type, the ability to add products to the main navigation isn’t really necessary, so let’s go ahead and disable that feature. So let me close this tab and I will uncheck main navigation.
Once you have configured everything, go ahead and click on save and manage fields. Once the form has been saved, you are redirected to the manage fields page, where you can start adding fields to the content type. Now you can already see that we have a body field. This field is automatically created on every new content type. And if we go to content and then add content, we should see our product content type with the description of used for selling products. And then if we click on it, we can see the product content form with the title field, body field, the published checkbox, which is checked by default, and then on the right, we can see revision log message, because we have configured the content type to create a new revision every single time content has been updated.