Watch videos with subtitles in your language, upload your videos, create your own subtitles! Click here to learn more on "how to Dotsub"

Adding Basic Fields to a Content Type

0 (0 Likes / 0 Dislikes)
Adding Basic Fields to a Content Type with Amber Matz In this tutorial we'll walk through the process of adding basic fields to a content type. By the end of this tutorial, you will understand how to add a link field and an image field to the Vendor content type. To follow along, you should understand the concepts of content entities and fields. See the written version of this tutorial for a link to the prerequisite. In the Manage administrative Menu, navigate to Structure, then Content types. This is the path admin/structure/types. Then click Manage fields in the drop-down button for the Vendor content type. The Manage fields page appears. Click Add field. The Add field page appears. You can either create a new field for this content type or reuse an existing field. Let's select the field type Link for our first new field. Next, we'll give it a label that will be viewable in administrative pages. Enter Vendor URL. Click Edit next to the generated machine name if you want to change it. Next, click Save and continue. We can now start to edit this field's global settings in the page Vendor URL that appears. First, we'll set the allowed number of values for this field. We'll enter a limited number and 1, which is the default. Now click Save field settings. We are directed to configure this field settings as it exists in the Vendor content type. The Label is the label that is visible in the content form. We'll keep the default, Vendor URL. Help text is where you can specify instructions which will be shown below the field in the content form. We'll leave this blank but this is a great place to document to your content editors what kind of values are expected for this field or any other special instructions. The Required field allows you to decide whether the field is required or not. This will be an optional field so we'll ensure this field is unchecked. If you want to add a default value for this field, you could do so here, but we'll leave this blank for this example. The Allowed link type field allows you to specify the kind of links that can be entered. We only want external links to be entered for this field. Such as the Vendor's own website and not any internal links. So we'll select External links only. Allow link text allows you to specify whether a link text can be entered. We'll select disabled, but if you wanted to allow editors of this type to specify custom text to link, this would be the place to allow that. Click Save settings. The Vendor URL has been added to the Content type. Now let's create another new field, the Main image field for this content type. Click Add field. The Add field page appears. Select a field type of Image and give it a label of Main image. Click Save and continue. The Main image page appears where we begin to configure our field settings. For Allowed number of values, enter Limited and 1. You can also set an optional default image here. This will be used when you do not provide an image when creating a Vendor content item. Click Save field settings. The Main image settings for Vendor page appears. For Label, enter Main image. For Help text, we'll leave this blank. For Required field, we'll check this to make it required. We'll skip over Default image and next for allowed file extensions, we'll keep the defaults here. But this is the field where you could add more file extensions. Separate them by a comma. In the File directory field, we can keep our files directory well organized. Here we can specify the directory where the files will be stored. We'll replace these date tokens with the value Vendors. This will be a subdirectory of your public files directory. For example, Sites default files. We'll skip Maximum image resolution but specify a Minimum image resolution of 600 by 600. Let's also specify a Maximum upload size of 5 megabytes. In a separate tutorial, we'll cover Drupal's Image Styles module which allows us to create different image sizes. That's why we're using such a high value here because we'll be configuring image styles later on and we don't want to put ourselves in a position where images are getting up-scaled and losing quality. Next we'll ensure that Enable Alt field and Alt field required are both checked, but we'll leave unchecked, Enable title field. Click Save settings. The Main image field has been added to the content type. Now you're ready to add some fields on your own. First, navigate to the Recipe content types manage fields page. I'll use the breadcrumb here to head back to Content types and then for Recipe, I'll click Manage fields. Instead of adding a new field, reuse an existing field and add the Main image field to the Recipe content type. Because you're reusing a field, some of the configuration will look a little different. For example, you won't be able to change how many values are allowed for this field. See the written version of this tutorial for further instructions, links to related tutorials, as well as links to further your understanding of this topic. In this tutorial, we added a link field and an image field to the Vendor content type.

Video Details

Duration: 5 minutes and 53 seconds
Country: United States
Language: English
License: All rights reserved
Genre: None
Views: 1
Posted by: drupalizeme on Nov 30, 2017

Adding Basic Fields to a Content Type

Caption and Translate

    Sign In/Register for Dotsub to translate this video.