Between a Block and a Hard Place - Extending Drupal 8 Blocks
The block system in Drupal 7 (the hard place) felt clunky and not very flexible most of the time. The release of Drupal 8 however brings with it a completely overhauled Block API system, in which blocks are now entities. While this is a priceless tool that developers have been wanting for a while, it can be a bit daunting at first when trying to create a block in code. This session dives into the powerful features of the Drupal 8 block system, as well as highlights some gotchas and best practices. Through a streamlined demo, this session starts with the bare minimum to get a block plugin up and running and finishes by leveraging new block features to add custom configuration like never before.
In this session you will learn how to define and place various parts of a block entity through custom code. This includes:
- What is a block plugin and why do I want to know about it?
- Creating a block plugin
- Adding custom configuration to a block plugin
- Placing a block plugin
- Exporting a block plugin
- Importing a block plugin
Leave this session knowing how to write, install, and configure a block plugin from scratch, as well as how to use new features that come with blocks on your Drupal 8 sites. It helps to have some exposure to Drupal 8 or at least have a good understanding of how object-oriented PHP works.
This is meant to be a hands-on session and participants are encouraged to follow along on their own computers with the provided example code. To be prepared for this session, please clone the Drupal 8 site in advance from the repo site (being rebuilt) and install the site as you would normally.