Table of Contents for
Drupal 8 Quick Start Guide

Version ebook / Retour

Cover image for bash Cookbook, 2nd Edition Drupal 8 Quick Start Guide by J. Ayen Green Published by Packt Publishing, 2018
  1. Drupal 8 Quick Start Guide
  2. Title Page
  3. Copyright and Credits
  4. Drupal 8 Quick Start Guide
  5. Dedication
  6. Packt Upsell
  7. Why subscribe?
  8. Packt.com
  9. Contributors
  10. About the author
  11. About the reviewers
  12. Packt is searching for authors like you
  13. Table of Contents
  14. Preface
  15. Who this book is for
  16. What this book covers
  17. To get the most out of this book
  18. Download the color images
  19. Conventions used
  20. Get in touch
  21. Reviews
  22. Finding Your Way around Drupal
  23. Installing Drupal
  24. Readying the environment
  25. Running the Drupal installation script
  26. Site information
  27. Site maintenance account
  28. Regional settings
  29. Update notifications
  30. The behind-the-scenes tour
  31. Administration menu
  32. Tabs
  33. System message area
  34. Search widget
  35. User menu
  36. Main navigation
  37. Main content area
  38. Summary
  39. Structuring Content Types
  40. What is content?
  41. Content as fields
  42. Understanding content types
  43. Defining the content type
  44. Submission form settings
  45. Publishing options
  46. Display settings
  47. Menu settings
  48. Managing content type fields
  49. Designing a content type
  50. Content type settings
  51. Fielding the content type
  52. Field types
  53. Our content type field
  54. Adding fields to the content type
  55. Summary
  56. Managing Users
  57. User types
  58. User roles
  59. Managing permissions
  60. Users
  61. Creating a user account
  62. Summary
  63. Creating and Editing Content
  64. Using the WYSIWYG editor
  65. Title*
  66. Body
  67. Summary Field
  68. Body text
  69. Text format
  70. Tags
  71. Images
  72. Publishing the content
  73. Additional settings
  74. Revision log message
  75. Menu Settings
  76. Comment Settings
  77. URL Path Settings
  78. Authoring Information
  79. Promotion Options
  80. Completing the process
  81. Summary
  82. Making Drupal Even More Useful
  83. Pathauto
  84. Paragraphs
  85. Content moderation
  86. States
  87. Transitions
  88. Workflow application
  89. Summary
  90. Grabbing Global Readership
  91. Declaring additional languages
  92. Translating content
  93. User language selection
  94. Translating the user interface
  95. Summary
  96. Feeding the Masses – RSS
  97. Why feeds?
  98. Selecting content for a feed
  99. Modifying content for feed selection
  100. Pick-me flags
  101. Tags
  102. Views
  103. Creating the container view
  104. Creating the Pets feed
  105. Display name
  106. Title
  107. Format
  108. Feed settings
  109. Filtering the criteria
  110. Sort criteria
  111. Creating the Travel feed
  112. Title
  113. Feed settings
  114. Format
  115. Filtering criteria
  116. Creating the Leftovers feed
  117. Title
  118. Feed settings
  119. Format
  120. Filtering criteria
  121. Creating the Feed Links block
  122. Summary
  123. Welcome Home!
  124. BAD home page!
  125. Design improvements
  126. Too much content!
  127. No access to content
  128. No RSS feeds menu
  129. We need a Terms and Conditions page
  130. Making the changes
  131. Improving the Frontpage view
  132. Title
  133. Format
  134. Fields
  135. Filtering criteria
  136. Block settings
  137. Pager
  138. Adding an Archive
  139. Adding the RSS Feeds menu
  140. Fixing the Footer menu
  141. Summary
  142. Other Books You May Enjoy
  143. Leave a review - let other readers know what you think

Adding fields to the content type

Still on the Manage fields page (/admin/structure/types/manage/appointment/fields), let's first make a change to the one existing field: Body. We will not have body text in this content type, so:

  1. Click the arrow next to Edit
  2. Select Delete
  3. confirm the deletion

With that done, click the +Add field button.

We'll add the fields shown in the preceding order for the most part. The page we see now has two dropdown select widgets: one for creating a new field, and one for reusing a field on this content type that already exists. 

Keeping in mind that the Name field already exists in our content type, being the renamed Title field that all content types contain, the first field we will add is Client phone number:

  1. Click on the Add a new field dropdown
  2. Scroll down and select Text (plain) from the list.

A new field, Label, appears, and is marked with a red asterisk, indicating that it is required that you type something in the field:

  • The label, as found in our preceding table, will be Phone

Having entered the label, you will notice that to the right of the field that a Machine name appears. The machine name is the name by which Drupal will identify the field. Once you save the field, the label can be changed at any time, but the field name will not change, because it will already have been set in stone within the database. Were you to desire a specific machine name, now is the time it can be changed, by clicking the Edit link. You would be able to edit the name, keeping in mind that there are some naming rules, such as needing to use underscores rather than hyphens, and that the field_ prefix cannot be removed. We have no need to override the field name:

  • Click Save and continue

A new page is loaded, which is for defining the field storage. Fields in Drupal have three components: the definition, which describes the field, the storage, which defines how the field will be stored in the database, and the actual contents of the field for a given piece of content, when that content is created.

The first field is Maximum length, and is required. For this field type, a standard (as opposed to long) text field is desired. The default is 255, meaning that the field can hold up to 255 characters. It's alright if less are entered when the content is created. You need only change this value if the contents should be of a particular length and no more. In the case of the phone field, it depends. If all client contacts will be local, or at least domestic, then it would be alright to limit the length to match the structure of your phone numbers. For example, in the U.S., phone numbers are ten digits. That said, the length of such a phone number can be greater than ten digits if entered with a format such as (212) 555-1212. So, be careful when limiting the length. We'll just leave it at 255.

The Allowed number of values field defines whether a piece of content, an appointment in this case, can contain more than one occurrence of this field. We have the option to leave it as Limited to one value, or change the number to another specific quantity, or click the dropdown widget and selecting Unlimited to indicated any number of instances of this field can be created. We want to be able to take two contact numbers for the client in case the need to contact them arises and attempts of using the first number are not successful:

  1. Change the 1 to 2
  2. Click Save field settings

The third, and final, page in the field creation process is now displayed. If we want to change the storage settings that we just saved, we could click the Field settings tab and do so.

The storage settings for a field can not be changed once content has been created that uses that field, unless all such content is first deleted. Attempts to click this tab after content has been created will result in a display of the settings with a message indicating that they can no longer be changed due to content existing.

The first field in the form is for the Label. This is the value that we entered earlier. It can be changed now if we have since decided on a new name. The Machine name can no longer be changed.

The contents of the Help text field, if any, will be displayed on the content form beneath the field you are creating. We'll use the entry from our table to provide the content creator with a hint as to the field contents, which in our case is the format of the phone number used locally:

  • Enter ###-###-#### in the Help Text field

The Help Text field can contain HTML, as indicated by its own help text. For example, we could elaborate on our description by instead entering the following:

Enter a phone number with the format <strong>###-###-####</strong>

Which would be displayed as follows:

Enter a phone number with the format ###-###-####

The next field in the form is the Required field. If this box is checked, the field will appear in the content form with its label containing whatever formatting is defined for a required field in the site theme. By default, this would be a red asterisk, as we see in the current form beside Label

If a field is required, content cannot be saved unless a value has been provided for the field. Be careful not to require a field that could legitimately be left empty. Examples of this are a zip code or post code for an optional address, a list of options where none may apply, or a checkbox, where empty indicates "no".

In our case, we will leave the phone field as not being required. The final field is for a default value. Of course, a phone number field is unlikely to have a default value, given that we have no idea what the value will be. There are circumstances where a default value makes sense. For example, if we have a grouping of address fields, one of which is Country, and if most of the entries will be from the United Kingdom, it would make sense to offer it as a default value rather than forcing the user to scroll down a list of countries to the U's. 

If you provide a default value, be prepared for erroneous content due to users accidentally leaving the field untouched and saving the form with the default value. 

We will leave the form containing no default value:

  • Click Save settings

At this point, we have saved our first field configuration, Phone. Technically, the field does not exist until content is created using this field, but its definition and configuration exist at this point. You can see that our content type field list for the Appointment content type has changed, with field_phone having been added to it.

We will follow the same process for each of the remaining fields in our table. For each of them, I note any considerations for their storage and configuration settings, as follows:

Datedate field type  the checkbox for Required should be checked.

With: list (text) field type  in the Allowed values list box, add 2-3 names in the form last name, first name, one person per line. As an example, I have added the following:

Jones, Janet
Smith, Steve

Status: list (text) field type – in the Allowed values list box, add the following:

pending
active
canceled
completed

And in the Default Value dropdown, select pending.

Having created all of the fields in our table, the Manage Fields page should look as follows: