Preprocessing Paragraphs: A Beginner's Guide
summary
A practical four-step recipe for Drupal 8 paragraph preprocessing: hook_theme to declare paragraph types, a dedicated preprocessor class with per-paragraph methods, register it as a service in services.yml, and call template_preprocess_paragraph to return render arrays wired to paragraph Twig templates. Covers loading nested entity references, creating custom render arrays instead of view modes, and debugging with Twig var-dump and Symfony VarDumper plus a memory-inspection trick; sample repo chromatic_paragraphs is provided.
AI-written summary · about
chapters (10)
- 0:00Introduction and setup
- 4:13Learning objectives
- 5:14Paragraph module overview
- 6:30The pre-processing recipe
- 8:28Implementing the workflow
- 13:05Optimization with services
- 15:32Handling nested entities
- 17:10Component-based use cases
- 19:16Debugging techniques
- 20:56Q&A and closing remarks
related talks
01h 01mDrupal 8 theme best practices - here's where we burried the bodies
59mGetting the most out of PHPStorm for Drupal 8
18mCreate and theme amazing PDFs using Drupal 8
33mOOP - The Pokemon Journey
41mWhat’s New in Drupal 8?
42mDrupal8 for Symfony developers
07mCreating Twig Extensions
42mDrupal8 for Symfony developers
