2.1 Demonstrate ability to create and configure Content Types with appropriate fields and field sett

Review what a content type is and how to display content in different methods.

In Drupal, a Content Type consists of the following primary elements:

  • Content type: base configuration

  • Content type: fields

Base configuration:

The base configuration of a content type defines the default behavior and properties of the content type. Examples include whether or not a newly created item of content has the status of _published_by default; or whether or not a newly created item of content is associated with one or more menus.

Moreover, the base configuration of a content type may also permit other additional custom settings provided by add-on modules.

Fields:

Content Types permit the creation of a set of fields that are associated together in some meaningful way.

Content Types are the building blocks for structured authoring in Drupal. Content types often work in conjunction with Views, which is one way you can serve up content to your end users; you can control the content types that appear and the order in which they appear. Developers can also customize the authoring experience in the same way.

From: drupal.org/working-with-content-types-and-fields-drupal-7-and-later

Create a new Content Type

Navigate to /admin/structure/types

To manage fields click on the storage settings for each field on each content type.

configuration yml file for node.type.article.yml

uuid: 5eb519c6-4ac4-4732-a276-06d8cc71c2fd
langcode: en
status: true
dependencies: { }
_core:
default_config_hash: AeW1SEDgb1OTQACAWGhzvMknMYAJlcZu0jljfeU3oso
name: Article
type: article
description: 'Use <em>articles</em> for time-sensitive content like news, press releases or blog posts.'
help: ''
new_revision: true
preview_mode: 1
display_submitted: true

Create and configure fields

Navigate to: admin/structure/types/manage/article/fields

To update field configuration click on the storage settings. Below is an example of the image field on the article content type.

Navigate to: /admin/structure/types/manage/article/fields/node.article.field\_image/storage If you want to see a list of all fields on the entire site, you can also navigate to: admin/reports/fields

configuration yml file for field.field.node.article.field_image.yml

uuid: b3a1e9d8-c78d-43c4-9eaf-8000460c5d72
langcode: en
status: true
dependencies:
config:
- field.storage.node.field_image
- node.type.article
module:
- image
_core:
default_config_hash: tgJzhA7Swh4M_gWU5FwFe5lPxPj5rebpMbvhpdNrERs
id: node.article.field_image
field_name: field_image
entity_type: node
bundle: article
label: Image
description: ''
required: false
translatable: true
default_value: { }
default_value_callback: ''
settings:
file_directory: '[date:custom:Y]-[date:custom:m]'
file_extensions: 'png gif jpg jpeg'
max_filesize: ''
max_resolution: ''
min_resolution: ''
alt_field: true
title_field: false
alt_field_required: true
title_field_required: false
default_image:
uuid: null
alt: ''
title: ''
width: null
height: null
handler: 'default:file'
handler_settings: { }
field_type: image

configuration yml file for field.storage.node.field_image.yml

uuid: 2303702c-836e-48bc-aa7e-f8efc6cee9a8
langcode: en
status: true
dependencies:
module:
- file
- image
- node
_core:
default_config_hash: SkXIPKZYiIMMtnBmfnxk58RYfbZ8cHSw5NZPY_JByME
id: node.field_image
field_name: field_image
entity_type: node
type: image
settings:
uri_scheme: public
default_image:
uuid: null
alt: ''
title: ''
width: null
height: null
target_type: file
display_field: false
display_default: false
module: image
locked: false
cardinality: 1
translatable: true
indexes:
target_id:
- target_id
persist_with_no_fields: false
custom_storage: false

Other Resources