35,99 €
This new and improved third edition cookbook is packed with the latest Drupal 10 features such as a new, flexible default frontend theme - Olivero, and improved administrative experience with a new theme - Claro. This comprehensive recipe book provides updated content on the WYSIWYG (What You See Is What You Get) editing experience, improved core code performance, and code cleanup.
Drupal 10 Development Cookbook begins by helping you create and manage a Drupal site. Next, you’ll get acquainted with configuring the content structure and editing content. You’ll also get to grips with all new updates of this edition, such as creating custom pages, accessing and working with entities, running and writing tests with Drupal, migrating external data into Drupal, and turning Drupal into an API platform. As you advance, you’ll learn how to customize Drupal’s features with out-of-the-box modules, contribute extensions, and write custom code to extend Drupal.
By the end of this book, you’ll be able to create and manage Drupal sites, customize them to your requirements, and build custom code to deliver your projects.
Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:
Seitenzahl: 426
Veröffentlichungsjahr: 2023
Practical recipes to harness the power of Drupal for building digital experiences and dynamic websites
Matt Glaman
Kevin Quillen
BIRMINGHAM—MUMBAI
Copyright © 2023 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
Associate Group Product Manager: Alok Dhuri
Publishing Product Manager: Akshay Dani
Content Development Editor: Rosal Colaco
Technical Editor: Maran Fernandes
Copy Editor: Safis Editing
Project Coordinator: Manisha Singh
Proofreader: Safis Editing
Indexer: Manju Arasan
Production Designer: Prashant Ghare
Business Development Executive: Puneet Kaur
Developer Relations Marketing Executive: Rayyan Khan and Deepak Kumar
First published: March 2016
Second edition: September 2017
Third edition: January 2023
Production reference: 1200123
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.
ISBN 978-1-80323-496-0
www.packtpub.com
Matt Glaman is an open source developer who has been working with Drupal since 2013. Since then, he has contributed to Drupal core and over 60 community projects. He is also a speaker at multiple Drupal community events, including DrupalCon. Matt is currently a principal software engineer at Acquia and was previously a product lead at Centarro, helping maintain Drupal Commerce.
I would like to thank, and am grateful to, my beautiful and loving wife for putting up with the late nights split between work, spending time contributing to the Drupal community, and writing this book. I would also like to thank my children; thank you for giving up your playtime so that Daddy could write this book.
Thank you, Andy Giles, for helping get me to my first Drupal camp and kicking off my Drupal career. I would also like to thank my mentors, Bojan Živanović, David Snopek, and Ryan Szrama, as well as everyone else in the Drupal community!
Kevin Quillen has been working with Drupal since 2006. He’s contributed several community modules, and built websites using Drupal for brands such as Dogfish Head Craft Brewery, the National Bureau of Economics, Harvard University, MTV, Yale University, Verizon, the Museum of Science, and countless others. You can find him engaged and helping community members on Slack, Drupal StackExchange, or sharing his thoughts on his personal blog. Kevin is also an Acquia Triple Certified Drupal Expert, an Acquia Certified Site Studio Site Builder, and an Acquia Certified Cloud Platform Pro. He is currently a principal developer and Drupal practice lead at Velir.
Thank you to years of unyielding support from family, friends, and colleagues who believe I can go the distance and continually push me to succeed. I am also eternally grateful and extremely thankful to the entire Drupal community and everyone I have met along the way as a result. Let’s continue the journey!
Justin Cornell is a Software Engineering Lead with 10 years of Drupal experience. He has developed and led teams through web projects ranging from brochure-style sites for local businesses to complex, high-traffic web applications for global industry leaders..
Tyler Marshall has been a professional full-stack developer since 2013. He started working at a small web development company specializing in Drupal for e-commerce. Since then, he has worked in a variety of fields and gained experience at many different software companies. As of 2019, Tyler now works full time for his own software development company at Dovetail Digital Inc. He is currently focusing on building projects using the MACH architecture and building automation software for his 3D printing company, Gamer Gadgetry. During his time off, you can find him training in Brazilian jiu-jitsu, fishing, spending time with loved ones, or thinking about his next big software project to take on.
Francesco Placella is a software engineer with over 15 years of experience in web design and development. He has been contributing to Drupal core since 2009. Having performed foundational work in terms of entities, language negotiation, and content translation, he has served as a subsystem maintainer and subsequently as a core committer since 2020. He currently works for Tag1 Consulting, which he joined after running his own web agency for 7 years in Venice, Italy.
Preface
Up and Running with Drupal
Content Building Experience
Displaying Content through Views
Extending Drupal with Custom Code
Creating Custom Pages
Accessing and Working with Entities
Creating Forms with the Form API
Plug and Play with Plugins
Creating Custom Entity Types
Theming and Frontend Development
Multilingual and Internationalization
Building APIs with Drupal
Writing Automated Tests in Drupal
Migrating External Data into Drupal
Index
Other Books You May Enjoy
Drupal is a popular content management system used to build websites for small businesses, e-commerce, enterprise systems, and much more. Created by over 4,500 contributors, Drupal 10 brings many new features to Drupal. Whether you are new to Drupal or an experienced Drupalista, Drupal 10 Development Cookbook contains recipes to dive into what Drupal 10 has to offer. We begin by helping you create and maintain your Drupal site. Next, familiarize yourself with configuring content structure and editing content. You can also find out about all new updates for this edition. These include creating custom pages, accessing and manipulating entities, running and creating tests using Drupal, and migrating external data to Drupal. As you progress, you'll learn how to customize Drupal's functionality using out-of-the-box modules, provide extensions, and write custom code to extend Drupal. You will also learn how to design a digital experience platform with robust content management and editorial workflows.
You can adapt Drupal to your needs by writing custom modules to create custom plugins, entity types, and pages. You can also power your Drupal site with modern front-end development build tools. You'll be able to create and manage code bases for Drupal sites. You can take advantage of Drupal by making Drupal your API platform, and serving content to your consumers.
Chapter 1, Up and Running with Drupal, walks through how to create a new Drupal site and the system requirements for running Drupal, and then run the Drupal site locally using modern local development tools based around Docker.
Chapter 2, Content Building Experience, dives into how to set up your content editing experience and add an editorial review workflow.
Chapter 3, Displaying Content through Views, walks through creating a page to list blogs and a companion block to display five of the most recent blogs using the views module, a visual query builder.
Chapter 4, Extending Drupal with Custom Code, explores how to create a custom module that can be installed onto your Drupal site.
Chapter 5, Creating Custom Pages, demonstrates how to create custom pages with controllers and routes. Creating custom pages allows you to extend Drupal beyond just content pages.
Chapter 6, Accessing and Working with Entities, covers create, read, update, and delete (CRUD) operations when working with entities in Drupal. We will create a series of routes to create, read, update, and delete nodes that are articles.
Chapter 7, Creating Forms with the Form API, covers the usage of the Form API, which is used to create forms in Drupal without writing any HTML.
Chapter 8, Plug and Play with Plugins, covers implementing a block plugin. We will use the Plugin API to provide a custom field type along with a widget and a formatter for the field. The last recipe will show you how to create and use a custom plugin type.
Chapter 9, Creating Custom Entity Types, explains how to create custom entity types for custom data models.
Chapter 10, Theming and Frontend Development, covers how to create a theme, work with the Twig templating system, and harness Drupal’s responsive design features.
Chapter 11, Multilingual and Internationalization, demonstrates the multilingual and internationalization features of Drupal 10,
Chapter 12, Building APIs with Drupal, walks through how to create RESTful APIs in Drupal with JSON:API, showing you how to read and manipulate data through HTTP requests.
Chapter 13, Running and Writing Tests with Drupal, dives into running and writing automated tests with PHPUnit for your custom module code.
Chapter 14, Migrating External Data into Drupal, explains how to migrate from an older version of Drupal to Drupal 10, and walks through using the Migration module to migrate content and data from CSV files and HTTP APIs.
In order to work with Drupal 10 and to run the code examples found in this book, the following software will be required:
Software
Operating system requirements
A local web server running in Docker (DDEV, Lando, Docksal, or Docker4Drupal) or an alternative such as MAMP
Windows, macOS, or Linux
PhpStorm or VS Code for code editing
Windows, macOS, or Linux
Terminal, iTerm, or a similar command-line tool
Windows, macOS, or Linux
NodeJS, npm, and Laravel Mix
Windows, macOS, or Linux
Note that there are several free open source tools that you can use to run Drupal locally – DDEV, Lando, Docksal, and Docker4Drupal are the top four community solutions. You are advised to use the one you are most comfortable with or already established with. This book’s first chapter covers running Drupal with DDEV. Unfortunately, we cannot cover all possible solutions in depth.
It is a good idea to keep the documentation of whichever solution you use handy when using this book, as examples may be generalized, particularly when it comes to running commands.
This book is for those who have been working with Drupal, such as site builders, backend and frontend developers, and those who are eager to see what awaits them when they start using Drupal 10.
In this book, you will find several headings that appear frequently (Getting ready, Howto do it…, How it works…, There’s more…, and See also).
To give clear instructions on how to complete a recipe, we use these sections as follows.
This section tells you what to expect in the recipe, and describes how to set up any software or preliminary settings required for the recipe.
This section contains the steps required to follow the recipe.
This section usually consists of a detailed explanation of what happened in the previous section.
This section consists of additional information about the recipe in order to make you more knowledgeable about the recipe.
This section provides helpful links to other useful information for the recipe.
We also provide a PDF file that has color images of the screenshots and diagrams used in this book. You can download it here: https://packt.link/N7EpQ.
You can download the example code files for this book from GitHub at https://github.com/PacktPublishing/Drupal-10-Development-Cookbook. If there’s an update to the code, it will be updated in the GitHub repository.
We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!
In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.
Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: “Create a file named Announcement.php in the newly created directory so that we can define the Announcement class for our entity type.”
A block of code is set as follows:
{% for tag in node.getTags %} <div>Tag: {{ tag.label }}</div> {% endfor %}Any command-line input or output is written as follows:
mkdir -p src/EntityNew terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: “You will see the generated permissions on the Permissions form.”
Tips or important notes
Appear like this.
Feedback from our readers is always welcome.
General feedback: If you have questions about any aspect of this book, email us at [email protected] and mention the book title in the subject of your message.
Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packtpub.com/support/errata and fill in the form.
Piracy: If you come across any illegal copies of our works in any form on the internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected] with a link to the material.
If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.
Once you’ve read Drupal 10 Development Cookbook, we’d love to hear your thoughts! Please click here to go straight to the Amazon review page for this book and share your feedback.
Your review is important to us and the tech community and will help us make sure we’re delivering excellent quality content.
Thanks for purchasing this book!
Do you like to read on the go but are unable to carry your print books everywhere? Is your eBook purchase not compatible with the device of your choice?
Don’t worry, now with every Packt book you get a DRM-free PDF version of that book at no cost.
Read anywhere, any place, on any device. Search, copy, and paste code from your favorite technical books directly into your application.
The perks don’t stop there, you can get exclusive access to discounts, newsletters, and great free content in your inbox daily
Follow these simple steps to get the benefits:
Scan the QR code or visit the link belowhttps://packt.link/free-ebook/9781803234960
Submit your proof of purchaseThat’s it! We’ll send your free PDF and other benefits to your email directly