Componentizer
A tiny MVC for WordPress components
Davo Hynds
A Certified B Corporation and one of Illinois’ first legal Benefit Corporations, Mightybytes is a digital firm committed to creating positive environmental and social change while providing unparalleled support to our clients.
Itinerary
Why did I build Componentizer?
The Challenge
Full comps for each template was unwieldy and time consuming
Our Approach
Breaking down templates into modularized components.
Inspiration from Atomic Design and Object Orient Design
http://bradfrost.com/blog/post/atomic-web-design/
It worked! Kind of...
Another Problem
Inflexibility led to unmet expectations for CMS admins
MOAR PROBLEMS
But... �WordPress themes are template driven
Introducing: Componentizer
Itinerary
What is Componentizer?
What is Componentizer?
Componentizer is a tiny MVC for components, allowing users to create and rearrange components at will.
Componentizer makes use of the WordPress template hierarchy, making it easy to customize the design of components depending on their context.
Componentizer is a plugin.
DRY
Don’t Repeat Yourself
Don’t Repeat Yourself
Don’t Repeat Yourself
Extendable
Models & Views
How does it work?
Model
Advanced Custom Fields Pro
View
Timber Library (uses the twig templating engine)
Controller
Componentizer and theme
Routing
Componentizer (based on the WordPress template hierarchy)
Dependencies
Plugins:
Also:
Template Hierarchy
Template Hierarchy
Template Hierarchy
Themes
The old way
Themes
The Componentizer way
Componentizer Suffixes
Componentizer Suffixes
Flow
User requests a page
Post’s components
Component
Controller
View
Itinerary
How do I use Componentizer?
Code, please.
Simply put, Componentizer allows you to replace the loop on every template file with:
Example: Page Header
Model Layer
Example: Page Header: ACF Fields
Controller Layer
Example: Page Header: Controllers
page_header-post.php
page_header.php
Renders: page_header-post.twig
Renders: page_header.twig
Example: Page Header: Controllers
page_header-post.php
page_header.php
Renders: page_header-post.twig
Renders: page_header.twig
Example: Page Header: Controllers
page_header-post.php
page_header.php
Renders: page_header-post.twig
Renders: page_header.twig
Example: Page Header: Controllers
page_header-post.php
page_header.php
Renders: page_header-post.twig
Renders: page_header.twig
View Layer
Example: Page Header: Views
Renders: page_header-post.twig
Renders: page_header.twig
Admins/Editors
Field Groups
Locations
Advanced
Site Editors
Itinerary
Caveats
No default editor, the_content();
Wha??? Why?
Cos I said so
Custom Page Templates
In summary
Flow
User requests a page
$components->build();
Post’s components (ACF)
Component
Controller
View
git clone https://github.com/dbhynds/componentizer.git
Questions?
Componentizer�https://github.com/dbhynds/componentizer
Davo Hynds�https://www.davohynds.com
Mightybytes�http://www.mightybytes.com