Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Drupal 8 Development Cookbook
Drupal 8 Development Cookbook

Drupal 8 Development Cookbook: Harness the power of Drupal 8 with this practical recipe-based guide , Second Edition

eBook
€8.99 €29.99
Paperback
€36.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Table of content icon View table of contents Preview book icon Preview Book

Drupal 8 Development Cookbook

The Content Authoring Experience

In this chapter, we will explore what Drupal 8 brings to the content authoring experience:

  • Configuring the WYSIWYG editor
  • Adding and editing content
  • Creating a menu and linking content
  • Providing inline editing
  • Creating a custom content type
  • Applying new Drupal 8 core field types
  • Customizing the form display of a node
  • Customizing the display output of a node

Introduction


In this chapter, we'll cover the Drupal 8 content authoring experience. We will show you how to configure text formats and set up the bundled CKEditor that ships with Drupal 8. We will take a look at how to add and manage content and utilize menus to link to content. Drupal 8 ships with inline editing for per-field modifications from the frontend.

This chapter dives into creating custom content types and harnessing different fields to create advanced content. We'll cover the five new fields added to Drupal 8 core and how to use them, along with configuring new field types through contributed projects. We will go through customizing the content's display and modifying the new form display added in Drupal 8.

Configuring the WYSIWYG editor


Drupal 8 saw the collaboration between the Drupal development community and the CKEditor development community. Because of this, Drupal now ships with CKEditor out of the box as the default What You See Is What You Get (WYSIWYG) editor. The new Editor module provides an API to integrate WYSIWYG editors. Although CKEditor is provided out of the box, contributed modules can provide integrations with other WYSIWYG editors.

Text formats control the formatting of content and WYSIWYG editor configuration for content authors. The standard Drupal installation profile provides a fully configured text format with the enabled CKEditor. We will walk through the steps of recreating this text format.

In this recipe, we will create a new text format with a custom CKEditor WYSIWYG configuration.

Getting ready

Before starting, make sure that the CKEditor module is enabled, which also requires Editor as a dependency. Editor is the module that provides an API to integrate WYSIWYG...

Adding and editing content


The main functionality of a content management system is in the name itself--the ability to manage content; that is, to add, edit, and organize content. Drupal provides a central form that allows you to manage all of the content within your website and allows you to create new content. Additionally, you can view a piece of content and click on an edit link when viewing it.

Getting ready

This recipe assumes that you have installed the standard installation profile and have the default node content types available for use.

How to do it...

Let's manage the content by adding, editing, and organizing the content:

  1. Go to Content to view the content management overview from.
  2. Click on Add content to view the list of available content types.
  3. Click on Article as the piece of content you would like to make.
  4. Provide a title for the piece of content. Titles are always required for content. Fill in the body text for the article:

Note

You may change the text format to customize what kind...

Creating a menu and linking content


Drupal provides a way to link content being authored to a specified menu on the website, generally the main menu. You can, however, create a custom menu to provide links to content. In this recipe, we will show you how to create a custom menu and link content to it. We will then place the menu as a block on the page, in the sidebar.

Getting ready

This recipe assumes that you have installed the standard installation profile and have the default node content types available for use. You should have some content created to create a link.

How to do it...

  1. Visit Structure and click on Menus.
  2. Click on Add menu.
  3. Provide the title Sidebar and optional summary and then click on Save.
  4. Once the menu is saved, click on the Add link button.
  5. Enter a link title and then type the title for a piece of content. The form will provide autocomplete suggestions for linkable content:
  1. Click on Save to save the menu link.
  2. With the menu link saved, go to Structure, and then Block layout....

Providing inline editing


A touted feature of Drupal 8 is the ability to provide inline editing. Inline editing is enabled by default with the standard installation profile through the Quick Edit module. The Quick Edit module allows editing individual fields while viewing a piece of content, and integrates it with the Editor module for WYSIWYG editors!

How to do it...

Let's provide inline editing:

  1. Go to a piece of created content.
  2. In order to enable inline editing, you must toggle contextual links on the page by clicking on Edit in the upper right of the administrative toolbar:
  1. This will toggle the contextual links available on the page. Click on the context link next to the content and select Quick edit:
  1. Hover over the body text and click on Edit. You can now edit the text with a minimal version of the WYSIWYG editor toolbar:
  1. Once you have changed the text, click on Save.
  2. The changes will be saved immediately.

How it works...

The Contextual links module provides privileged users with shortcut links...

Creating a custom content type


Drupal excels in the realm of content management by allowing different types of content. In this recipe, we will walk you through creating a custom content type. We will create a Services type that has some basic fields and would be used in a scenario that brings attention to a company's provided services.

You will also learn how to add fields to a content type in this recipe, which generally goes hand in hand with making a new content type on a Drupal site.

How to do it...

  1. Go to Structure and then Content types. Click on Add content type to begin creating a new content type.
  2. Enter Services as the name, and an optional description.
  3. Select Display settings and uncheck the Display author and date information checkbox. This will hide the author and submitted time from services pages:
  1. Click on the Save and manage fields button to save the new content type and manage its fields.
  2. By default, new content types have a Body field automatically added to them. We will keep this...

Applying new Drupal 8 core field types


The field system is what makes creating content in Drupal so robust. With Drupal 8, some of the most used contributed field types have been merged into Drupal core as their own module. In fact, Entity Reference is no longer a module but part of the main Field API now.

This recipe is actually a collection of mini-recipes to highlight the new fields provided by Drupal 8 core: Link, Email, Telephone, Date, and Entity reference.

Getting ready

The standard installation profile does not enable all of the modules that provide these field types by default. For this recipe, you will need to manually enable select modules so that you can create the field. The module that provides the field type and its installation status in the standard profile will be highlighted.

Each recipe will start off expecting that you have enabled the module, if needed, and that you are at the Manage fields form of a content type and have clicked on Add field and provided a field label...

Customizing the form display of a node


The latest in Drupal 8 is the availability of form display modes. Form modes allow a site administrator to configure different field configurations for each content entity bundle edit form. In the case of nodes, you have the ability to rearrange and alter the display of fields and properties on the node edit form.

In this recipe, we'll modify the default form for creating the Article content type that comes with the standard installation profile:

How to do it...

  1. To customize the form display mode, go to Structure and then Content Types.
  2. We will modify the Article content type's form. Click on the expand the OPERATIONS dropdown and select Manage form display.
  1. First, we will modify the Comments field. Click on the drag icon to the left and drag the row into the Disabled section. Follow the same steps for the sticky at top of lists field:
  1. Click on the settings cog for the Body field. Enter in a placeholder for the field, such as Enter your article text here...

Customizing the display output of a node


Drupal provides display view modes that allow for customization of the fields and other properties attached to an entity. In this recipe, we will adjust the teaser display mode of an Article. Each field or property has a control for displaying the label, the format to display the information in, and additional settings for the format.

Harnessing view displays allows you to have full control over how content is viewed on your Drupal site.

How to do it...

  1. Now, it is time to customize the form display mode by navigating to Structure and then Content Types.
  2. We will modify the Article content type's display. Click on the dropdown button arrow and select Manage display.
  3. Click on the Teaser view mode option to modify it. The teaser view mode is used in node listings, such as the default homepage:
  1. Change the format for Tags to be Hidden. Additionally, this can be accomplished by dragging it to the hidden section. The tags on an article will no longer be displayed...
Left arrow icon Right arrow icon

Key benefits

  • Discover the enhanced content authoring experience that comes with Drupal 8 and how to customize it
  • Take advantage of the broadened multilingual and tools of the new version to provide an internationalized website
  • This step-by-step guide will show you how to deploy from development, staging, and production of a website with Drupal 8's brand new configuration management system

Description

Began as a message board, Drupal today is open source software maintained and developed by a community of over 1,000,000 users and developers. Drupal is used by numerous local businesses to global corporations and diverse organizations all across the globe. With Drupal 8’s exciting features it brings, this book will be your go-to guide to experimenting with all of these features through helpful recipes. We’ll start by showing you how to customize and configure the Drupal environment as per your requirements, as well as how to install third-party libraries and then use them in the Drupal environment. Then we will move on to creating blocks and custom modules with the help of libraries. We will show you how to use the latest mobile-first feature of Drupal 8, which will help you make your apps responsive across all the major platforms. This book will also show you how to incorporate multilingual facilities in your sites, use web services and third-party plugins with your applications from inside Drupal 8, and test and deploy your apps.

Who is this book for?

The audience of the Drupal 8 Cookbook have been using Drupal and are ready to get a grasp of what to expect in Drupal 8. They have worked with Drupal as site builders, back-end developers, and front-end developers and are eager to see what awaits when they start using Drupal 8. This book will be a resource that allows them to get started and have a reference to building new applications with Drupal.

What you will learn

  • Extend Drupal through contributed or custom modules and themes
  • Develop an internationalized website with Drupal s multilingual tools
  • Integrate third-party front-end and back-end libraries with Drupal
  • Turn Drupal into a web services provider using REST
  • Create a mobile-first responsive Drupal application
  • Run SimpleTest and PHPUnit to test Drupal
  • Understand the plugin system that powers many of Drupal 8 s new APIs to extend its functionality
  • Get to grips with the mechanics of the configuration management system and the ability to import and export site configuration
Estimated delivery fee Deliver to Portugal

Premium delivery 7 - 10 business days

€17.95
(Includes tracking information)

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Sep 26, 2017
Length: 430 pages
Edition : 2nd
Language : English
ISBN-13 : 9781788290401
Languages :
Concepts :
Tools :

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Estimated delivery fee Deliver to Portugal

Premium delivery 7 - 10 business days

€17.95
(Includes tracking information)

Product Details

Publication date : Sep 26, 2017
Length: 430 pages
Edition : 2nd
Language : English
ISBN-13 : 9781788290401
Languages :
Concepts :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 106.97
Drupal 8 Blueprints
€32.99
Drupal 8 Development Cookbook
€36.99
Drupal 8 Module Development
€36.99
Total 106.97 Stars icon
Banner background image

Table of Contents

13 Chapters
Up and Running with Drupal 8 Chevron down icon Chevron up icon
The Content Authoring Experience Chevron down icon Chevron up icon
Displaying Content through Views Chevron down icon Chevron up icon
Extending Drupal Chevron down icon Chevron up icon
Frontend for the Win Chevron down icon Chevron up icon
Creating Forms with the Form API Chevron down icon Chevron up icon
Plug and Play with Plugins Chevron down icon Chevron up icon
Multilingual and Internationalization Chevron down icon Chevron up icon
Configuration Management - Deploying in Drupal 8 Chevron down icon Chevron up icon
The Entity API Chevron down icon Chevron up icon
Off the Drupalicon Island Chevron down icon Chevron up icon
Web Services Chevron down icon Chevron up icon
The Drupal CLI Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.7
(3 Ratings)
5 star 66.7%
4 star 33.3%
3 star 0%
2 star 0%
1 star 0%
Alex Sluiter Nov 24, 2021
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Reads like a true cook book with quality executable examples. It’s something you can refer back to even after learning the inner workings of Drupal.
Amazon Verified review Amazon
Christian Apr 26, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Super useful and contains almost everything you need to know about drupal 8.I liked that it contained coding, site building but also deployment and testing.
Amazon Verified review Amazon
John Lewis Sep 08, 2018
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
Great introductory book on basic Drupal 8 concepts and how to use them, but the subject matter is so deep the cookbook style doesn't give enough depth of understanding. Yes, I see I have to create three files in these directories but I don't understand why and if I want to alter to recipe to be something different, how do I do that?It's exactly what it says it is, I should have skimmed the TOCs to see if there was a specific mention of the topic I needed help with. Drupal 8 is radically different than Drupal 7 and a cookbook isn't going to give you the understanding of how to move from one style to another.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on customercare@packt.com within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela