Drupal 8 Pages of Note
Where applicable, Drupal 8 knowledge is being added throughout the rest of the Developers Handbook. The following highlights some useful pages found elsewhere in the handbook.
CKEditor in Drupal 8 - What's new in CKEditor, and tips and tricks for extending and customizing it
Drupal 8 Guides
Getting Started Guide to Writing Drupal 8 Modules (also for migrating Drupal 7 modules to Drupal 8)
Drupal 8 Developers Cookbook - provides templates and quick-reference information for Drupal 8 module developers.
Drupal 8 Migration Process - Background and instructions for migrating a site from Drupal 7 to Drupal 8
Drupal 8 Migration Roadmap (GT) - List of commonly used modules and their Drupal 8 status
Drupal 8 Migration for Drupal Express - Roadmap specifically for Drupal Express based websites
Drupal 8 Internal Caching for Dummies - Beginner's guide to the Drupal 8 content caching system
Drupal 8 Site Technical Troubleshooting - Techniques for recovering from a "white screen of death" or worse.
Drupal 8 Tips and Tricks
This section is for tips and tricks specific to Drupal 8, which is quite different from it's predecessors, Drupal 7 and 6. Topics posted here will eventually be migrated into the main sections of this handbook after some mainstream adoption of Drupal 8 on campus has occurred.
Drupal 7 began forcing mySQL to act like a traditional SQL server so that all SQL code used in Drupal will be highly compatible with other database systems like PostgreSQL or SQLite. This means that mySQL statements that syntactically work in other contexts may produce errors under Drupal 7 or 8. Drupal 8 adds the 'ONLY_FULL_GROUP_BY' restriction, which can potentially cause custom mySQL code that worked in Drupal 7 to fail with errors in Drupal 8.
Here's the exact settings being used in Drupal 8:
- SET sql_mode = 'ANSI, STRICT_TRANS_TABLES, STRICT_ALL_TABLES, NO_ZERO_IN_DATE, NO_ZERO_DATE, ERROR_FOR_DIVISION_BY_ZERO, NO_AUTO_CREATE_USER, ONLY_FULL_GROUP_BY'
The mySQL Reference Guide has full details on these SQL modes and their effects. (See especially the section on STRICT mode and ONLY_FULL_GROUP_BY mode.)
Here's how to whitelist HTML tags in your module output that are normally stripped out by the XSS filter:
$tagList = array('input'); return array( '#markup' => $buffer, '#allowed_tags' => array_merge(\Drupal\Component\Utility\Xss::getAdminTagList(), $tagList), );
And here's how to allow data URLs in your module output for displaying images with data that you've already pulled in from a data source (code updated 2017-12-11 to a better format that avoids whitescreening in certain use cases):
$allowedProtocols = \Drupal\Component\Utility\URLHelper::getAllowedProtocols(); $allowedProtocols = 'data'; \Drupal\Component\Utility\URLHelper::setAllowedProtocols($allowedProtocols);
Here's a quick reference guide to working with the new configuration management system. You'll need this if you want to build a module that adds its own configuration to Drupal during its installation process:
Add additional tips and tricks here.