Building a Block-based Component Architecture

adamzimmermann

The wireframes were just sent your way. The content is a mix of global elements, entity-specific field values, dynamic displays of multi-field data, and some content listings; all with some ads mixed in. Your mind races with a thousand solutions as you try to visualize each discreet component created in field templates, node templates, Views templates, block templates, etc.

Instead of trying to create multiple components inside existing templates, what if each component was a block and was always a block? No longer is there a guessing game to determine where and how components should be built.

During this session we will explore the process of creating a consistent component based approach using blocks and cover the many benefits like:

  • Each component gets a unique class that compartmentalizes the functionality.
  • Groups of fields can rendered together apart from the node template.
  • Components can share functionality through inheritance since each component is a class.
  • The need for procedural preprocess functions drops greatly.
  • Components can share templates or use custom ones as needed.
  • Custom caching logic can be applied for each component.

Additionally, how you place all of your new blocks is up to you! That's the hidden benefit of this approach, it is not opinionated about the use of Panels, Display Suite, Context, Core's block layout tools, your homegrown solution, or the latest and greatest block layout module.

Attendees should have some experience with writing custom modules for Drupal 8.

Session Track

Front End

Experience Level

Intermediate

Drupal Version