SlideShare a Scribd company logo
Advanced layouts
and block
management
Ivo Lukač @ PHPCE, Poland 2017
www.netgenlabs.com
• Ivo Lukač, co-founder of Netgen, Croatia

Also: developer, site builder, architect, consultant, project manager,
evangelist, speaker, event organiser, business developer, …
• Netgen, web agency, Zagreb, Croatia, ~20 employees
• 15 years of experience building complex content-
centric web solutions, using eZ Publish since 2004,
Symfony since 2013.
• Clients and partners in Germany, Switzerland, Norway,
etc.
About me
www.netgenlabs.com
www.netgenlabs.com
HOW IT ALL STARTED
www.netgenlabs.com
We wanted to improve the
process of building
complex web solutions
and make it more efficient!
www.netgenlabs.com
We wanted to find the
intersection of typical web
project phases and
improve there
www.netgenlabs.com
So what is the common
ground for backend,
frontend, site building and
content?
www.netgenlabs.com
We figured its about
layouts and blocks :)
www.netgenlabs.com
- backend developers implement features
that need to be placed somewhere on the
interface (layout), reuse when necessary
- frontend developers apply design on
HTML markup which describes the layout
- editors place content in prepared blocks
- site builders manage the front interface
with set of layouts and blocks
Layouts and blocks
www.netgenlabs.com
- SaaS solutions like Webflow, Wix, etc
- not on enterprise level
- hard to extend
- prototyping/wireframing tools exporting to HTML/CSS
- what about backend?
- responsiveness still hard
- CMS specific tools
- usually focused on one page, one persona
Many ways to skin a cat
www.netgenlabs.com
NETGEN LAYOUTS
www.netgenlabs.com
www.netgenlabs.com
• Layout and Block Management System
• an independent view layer for content
driven sites/applications
• suppose to control all markup in <body>
• no WYSIWYG, doesn’t mess with
frontend (CSS/JS)
• highly extensible and customisable
What is it?
www.netgenlabs.com
• Symfony full stack
• uses Symfony routing and Twig extending feature
to inject Layouts
• Can be tightly coupled with Symfony full stack apps
• eZ Publish / eZ Platform
• PoC with Sylius eCommerce
• Could be loosely coupled with any other systems
• PoC with Contentful
Architecture
www.netgenlabs.com
• Separation of front and backend layer
• Implementing front layer for headless
backend(s)
• Deploying design systems
• Fast micro/additional site building
• 2-phase replacement of legacy systems
Use cases
www.netgenlabs.com
MAIN CONCEPTS
www.netgenlabs.com
• Layout - responsible to render the layout
of a page consisting of Zones with Blocks
• Zone - a placeholder for Blocks. More
Blocks can be added in a Zone, rendered
one after other
• Shared Layout - a special layout which
purpose is to hold Blocks in Zones that
can be linked (reused) in other Layouts
Defining layouts
www.netgenlabs.com
www.netgenlabs.com
• Block - responsible for handling specific
features. It renders a specified Block
View template. Blocks can use Items
from a specified Collection
• Collection:
• manual - items picked from the backend
• dynamic - Query fetches data from the
backend.
Defining blocks
www.netgenlabs.com
• Layout Resolver - decides what Layout
will be used for which request. It traverses
Layout mappings and picks the first one
which fits the requested URL and matches
additional conditions
Resolving layouts
www.netgenlabs.com
• Layout mappings - a configuration that defines
which Layout is applied to which Target URLs
under what Conditions
• Target - an abstraction which defines one or more
URLs in a generic or backend specific way (e.g.
home or all article URLs)
• Condition - additional matchers, could be anything
known in request context (e.g. type of content,
GET parameter, time of the day, user group, …)
Layout mappings
www.netgenlabs.com
WORKSHOP
www.netgenlabs.com
- use Contentful as content storage
- create a Symfony app that shows
content from Contentful and uses CMF
routing
- use Layouts to manage typical pages
The task
www.netgenlabs.com
- a headless cloud CMS
- features spaces and content types
- no content hierarchy
- provides REST API
- PHP SDK and Symfony bundle provide
abstraction of the API with a service for
each space - Client
Contentful
www.netgenlabs.com
Symfony 3.4 beta1
- install
- create new database
Step 0
www.netgenlabs.com
Contentful bundle
- require “contentful/contentful-bundle”
- enable and configure Contentful bundle
Step 1a
www.netgenlabs.com
- create Contentful service
- show configuration:

php	bin/console	contentful:info
- add caching for spaces and content
types
- run caching script:

php	bin/console	contentful:sync
Step 1b
www.netgenlabs.com
Symfony CMF dynamic router
- require “symfony-cmf/routing-bundle”
- install needed database tables:

php	bin/console	doctrine:schema:update	--force
- enable and configure Symfony CMF
routing
Step 2a
www.netgenlabs.com
- create Contentful entity, a local proxy for remote
Contentful entry (caching and routing purposes)
- extend Contentful service to load the Contentful
entity
- test loading of example Contentful entity
- verify new row in the database: 

mysql	phpce	-uroot	-p	-e	"select	*	from	orm_routes"
- try the route
Step 2b
www.netgenlabs.com
View Controller
- create Contentful entity view controller action
- configure CMF dynamic router to use it
- add content enhancer so the View controller
gets the Contentful entity
- try the route again
Step 3
www.netgenlabs.com
Netgen Layouts
- set private composer repo:

”repositories":	[	

			{	"type":	"composer",	"url":	"https://packagist.netgen.biz"	}

],
- require “netgen/block-manager”
- docs.netgen.io/projects/layouts/en/latest/
reference/install_instructions.html
Step 4a
www.netgenlabs.com
- install needed database tables:

php	bin/console	doctrine:migrations:migrate	--
configuration=vendor/netgen/block-manager/migrations/
doctrine.yml
- install assets:

php	bin/console	assets:install	--symlink	--relative
- enable Layouts and configure routing
- configure admin access with basic auth
Step 4b
www.netgenlabs.com
- inject Layouts Resolver in Twig
templates
- create “Home” layout
- map that layout to home URL
- create shared layout for header and right
column
Step 4c
www.netgenlabs.com
Manual item selection with Content Browser
- integrate Contentful bundle with
ContentBrowser
- docs.netgen.io/projects/cb/en/latest/cookbook/
index.html
- docs.netgen.io/projects/layouts/en/latest/
cookbook/custom_value_types.html
Step 5a
www.netgenlabs.com
- add Layouts item type for Contentful entity
- add ContentBrowser item types for
Contentful entity and client
- add ContentBrowser backend that
browses Contentful entities
- add additional ContentBrowser columns
for Contentful entity
Step 5b
www.netgenlabs.com
- include bootstrap4 CSS
- select products for home grid
- add images:
					{%	for	image	in	item.object.getImage()	%}

							<img	src="{{	image.getFile().getUrl()	}}?h=120&w=200"/>

					{%	endfor	%}	
- check route table:

mysql	phpce	-uroot	-p	-e	"select	*	from	orm_routes"
Step 5c
www.netgenlabs.com
Collection query
- docs.netgen.io/projects/layouts/en/latest/
cookbook/custom_query_types.html
- add Contentful collection query
- configure “latest posts” block
Step 6
www.netgenlabs.com
Layouts Resolver target
- docs.netgen.io/projects/layouts/en/latest/
cookbook/custom_target_types.html
- add 2 target types, for Contentful entity and
space
- add Twig extension for target type templates
- create a “product” layout and map it
Step 7
www.netgenlabs.com
Layouts Resolver condition
- docs.netgen.io/projects/layouts/en/latest/
cookbook/custom_condition_types.html
- add Layouts Resolver condition type for
Contentful content type
- use the condition for “product” layout
Step 8
www.netgenlabs.com
Contentful field block
- docs.netgen.io/projects/layouts/en/latest/
cookbook/custom_blocks.html
- add Contentful field block type
- create a “blog post” layout
Step 9
www.netgenlabs.com
Cache all Contentful entries
- finalize sync script
- run sync script:

php	bin/console	contentful:sync
- show debug info
Step 10
www.netgenlabs.com
HOW COULD IT LOOK
www.netgenlabs.com
- just released v0.9 with layout translation
capabilities
- adding more features (like user policies, ad-hoc
content etc.)
- launching projects based on Layouts and eZ
since end of 2016
- first launches by early adopters (agencies from
Germany, Italy) last month, several other starting
Currently
www.netgenlabs.com
- open source the core
- make it sustainable with commercial
add-ons
- integrate tightly with other Symfony
based systems
- make loose integrations with everything
else easy via REST/SOAP, …
Future
Thank you
ivo@netgen.hr
ilukac.com/twitter
ilukac.com/linkedin
joind.in/talk/3c584

More Related Content

PDF
Merging two big Symfony based applications - PHPCE 2017
PDF
Merging two big Symfony based applications - SymfonyCon 2017
PPT
Real World Rails Deployment
PPTX
Angular.js in XPages
PPTX
Testing your Single Page Application
PPTX
Hire laravel-php-developers- Hire Laravel Programmers
PDF
Agile sites311training
PPT
Basic web application development with Apache Cocoon 2.1
Merging two big Symfony based applications - PHPCE 2017
Merging two big Symfony based applications - SymfonyCon 2017
Real World Rails Deployment
Angular.js in XPages
Testing your Single Page Application
Hire laravel-php-developers- Hire Laravel Programmers
Agile sites311training
Basic web application development with Apache Cocoon 2.1

What's hot (20)

PDF
Moving from PHP to a nodejs full stack CMS
PPTX
Agile sites @ telmore
PPTX
Agile sites2
PPTX
The future of web development write once, run everywhere with angular.js and ...
PDF
Mobile Hybrid Development with WordPress
PPTX
Oleksandr Skachkov "Running С# in your Web Browser with WebAssembly"
PDF
Improve WordPress performance with caching and deferred execution of code
PDF
Extending WordPress as a pro
PPT
Ruby Setup
PDF
WordPress Development Tools and Best Practices
PDF
Using WordPress as a Headless CMS
PPTX
Using MAMP for Web Development
KEY
ClubAJAX Basics - Server Communication
PDF
IBM Domino Modernizing apps with Angularjs
PPTX
Tarabica 2019 - Migration from ASP.NET MVC to ASP.NET Core
PDF
Isomorphic web application
PPTX
Mobious(ES6 Isomorphic Flux/ReactJS Boilerplate)
PDF
Asp.Net 3 5 Part 1
PPTX
Migration from ASP.NET MVC to ASP.NET Core
PDF
One Neos CMS - many websites
Moving from PHP to a nodejs full stack CMS
Agile sites @ telmore
Agile sites2
The future of web development write once, run everywhere with angular.js and ...
Mobile Hybrid Development with WordPress
Oleksandr Skachkov "Running С# in your Web Browser with WebAssembly"
Improve WordPress performance with caching and deferred execution of code
Extending WordPress as a pro
Ruby Setup
WordPress Development Tools and Best Practices
Using WordPress as a Headless CMS
Using MAMP for Web Development
ClubAJAX Basics - Server Communication
IBM Domino Modernizing apps with Angularjs
Tarabica 2019 - Migration from ASP.NET MVC to ASP.NET Core
Isomorphic web application
Mobious(ES6 Isomorphic Flux/ReactJS Boilerplate)
Asp.Net 3 5 Part 1
Migration from ASP.NET MVC to ASP.NET Core
One Neos CMS - many websites
Ad

Similar to Contentful with Netgen Layouts workshop (20)

PDF
The new way of managing layouts and blocks
PDF
symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)
PDF
symfony_from_scratch
PDF
symfony_from_scratch
PDF
Next Generation Web Development Techniques with Cloud Foundry
PDF
Implementing a Symfony Based CMS in a Publishing Company
PDF
symfony: An Open-Source Framework for Professionals (PHP Day 2008)
PPTX
Building A Platform From Open Source At Yahoo
PDF
Pump up the JAM with Gatsby
PDF
Rise of the Content Mesh: Webcast with Contentful and Gatsby
KEY
Web frameworks don't matter
PDF
Symfony HTTP Kernel for refactoring legacy apps: the eZ Publish case study - ...
PDF
Ny symfony meetup may 2015
PDF
Масштабируемая конфигурация Nginx, Игорь Сысоев (Nginx)
PDF
Fitting Plone in a custom stack
PDF
20130528 solution linux_frousseau_nopain_webdev
PDF
Leverage HTTP to deliver cacheable websites - Thijs Feryn - Codemotion Rome 2018
PDF
Leverage HTTP to deliver cacheable websites - Codemotion Rome 2018
PDF
Developing cacheable PHP applications - PHPLimburgBE 2018
PDF
Surviving a Plane Crash, a NU.nl case-study
The new way of managing layouts and blocks
symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)
symfony_from_scratch
symfony_from_scratch
Next Generation Web Development Techniques with Cloud Foundry
Implementing a Symfony Based CMS in a Publishing Company
symfony: An Open-Source Framework for Professionals (PHP Day 2008)
Building A Platform From Open Source At Yahoo
Pump up the JAM with Gatsby
Rise of the Content Mesh: Webcast with Contentful and Gatsby
Web frameworks don't matter
Symfony HTTP Kernel for refactoring legacy apps: the eZ Publish case study - ...
Ny symfony meetup may 2015
Масштабируемая конфигурация Nginx, Игорь Сысоев (Nginx)
Fitting Plone in a custom stack
20130528 solution linux_frousseau_nopain_webdev
Leverage HTTP to deliver cacheable websites - Thijs Feryn - Codemotion Rome 2018
Leverage HTTP to deliver cacheable websites - Codemotion Rome 2018
Developing cacheable PHP applications - PHPLimburgBE 2018
Surviving a Plane Crash, a NU.nl case-study
Ad

Recently uploaded (20)

PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Approach and Philosophy of On baking technology
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
KodekX | Application Modernization Development
PPT
Teaching material agriculture food technology
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
A Presentation on Artificial Intelligence
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Electronic commerce courselecture one. Pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
MYSQL Presentation for SQL database connectivity
Approach and Philosophy of On baking technology
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
KodekX | Application Modernization Development
Teaching material agriculture food technology
Mobile App Security Testing_ A Comprehensive Guide.pdf
Unlocking AI with Model Context Protocol (MCP)
A Presentation on Artificial Intelligence
Review of recent advances in non-invasive hemoglobin estimation
Reach Out and Touch Someone: Haptics and Empathic Computing
Dropbox Q2 2025 Financial Results & Investor Presentation
Building Integrated photovoltaic BIPV_UPV.pdf
The Rise and Fall of 3GPP – Time for a Sabbatical?
Electronic commerce courselecture one. Pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Diabetes mellitus diagnosis method based random forest with bat algorithm
Understanding_Digital_Forensics_Presentation.pptx
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Digital-Transformation-Roadmap-for-Companies.pptx

Contentful with Netgen Layouts workshop

  • 1. Advanced layouts and block management Ivo Lukač @ PHPCE, Poland 2017
  • 2. www.netgenlabs.com • Ivo Lukač, co-founder of Netgen, Croatia
 Also: developer, site builder, architect, consultant, project manager, evangelist, speaker, event organiser, business developer, … • Netgen, web agency, Zagreb, Croatia, ~20 employees • 15 years of experience building complex content- centric web solutions, using eZ Publish since 2004, Symfony since 2013. • Clients and partners in Germany, Switzerland, Norway, etc. About me
  • 5. www.netgenlabs.com We wanted to improve the process of building complex web solutions and make it more efficient!
  • 6. www.netgenlabs.com We wanted to find the intersection of typical web project phases and improve there
  • 7. www.netgenlabs.com So what is the common ground for backend, frontend, site building and content?
  • 8. www.netgenlabs.com We figured its about layouts and blocks :)
  • 9. www.netgenlabs.com - backend developers implement features that need to be placed somewhere on the interface (layout), reuse when necessary - frontend developers apply design on HTML markup which describes the layout - editors place content in prepared blocks - site builders manage the front interface with set of layouts and blocks Layouts and blocks
  • 10. www.netgenlabs.com - SaaS solutions like Webflow, Wix, etc - not on enterprise level - hard to extend - prototyping/wireframing tools exporting to HTML/CSS - what about backend? - responsiveness still hard - CMS specific tools - usually focused on one page, one persona Many ways to skin a cat
  • 13. www.netgenlabs.com • Layout and Block Management System • an independent view layer for content driven sites/applications • suppose to control all markup in <body> • no WYSIWYG, doesn’t mess with frontend (CSS/JS) • highly extensible and customisable What is it?
  • 14. www.netgenlabs.com • Symfony full stack • uses Symfony routing and Twig extending feature to inject Layouts • Can be tightly coupled with Symfony full stack apps • eZ Publish / eZ Platform • PoC with Sylius eCommerce • Could be loosely coupled with any other systems • PoC with Contentful Architecture
  • 15. www.netgenlabs.com • Separation of front and backend layer • Implementing front layer for headless backend(s) • Deploying design systems • Fast micro/additional site building • 2-phase replacement of legacy systems Use cases
  • 17. www.netgenlabs.com • Layout - responsible to render the layout of a page consisting of Zones with Blocks • Zone - a placeholder for Blocks. More Blocks can be added in a Zone, rendered one after other • Shared Layout - a special layout which purpose is to hold Blocks in Zones that can be linked (reused) in other Layouts Defining layouts
  • 19. www.netgenlabs.com • Block - responsible for handling specific features. It renders a specified Block View template. Blocks can use Items from a specified Collection • Collection: • manual - items picked from the backend • dynamic - Query fetches data from the backend. Defining blocks
  • 20. www.netgenlabs.com • Layout Resolver - decides what Layout will be used for which request. It traverses Layout mappings and picks the first one which fits the requested URL and matches additional conditions Resolving layouts
  • 21. www.netgenlabs.com • Layout mappings - a configuration that defines which Layout is applied to which Target URLs under what Conditions • Target - an abstraction which defines one or more URLs in a generic or backend specific way (e.g. home or all article URLs) • Condition - additional matchers, could be anything known in request context (e.g. type of content, GET parameter, time of the day, user group, …) Layout mappings
  • 23. www.netgenlabs.com - use Contentful as content storage - create a Symfony app that shows content from Contentful and uses CMF routing - use Layouts to manage typical pages The task
  • 24. www.netgenlabs.com - a headless cloud CMS - features spaces and content types - no content hierarchy - provides REST API - PHP SDK and Symfony bundle provide abstraction of the API with a service for each space - Client Contentful
  • 25. www.netgenlabs.com Symfony 3.4 beta1 - install - create new database Step 0
  • 26. www.netgenlabs.com Contentful bundle - require “contentful/contentful-bundle” - enable and configure Contentful bundle Step 1a
  • 27. www.netgenlabs.com - create Contentful service - show configuration:
 php bin/console contentful:info - add caching for spaces and content types - run caching script:
 php bin/console contentful:sync Step 1b
  • 28. www.netgenlabs.com Symfony CMF dynamic router - require “symfony-cmf/routing-bundle” - install needed database tables:
 php bin/console doctrine:schema:update --force - enable and configure Symfony CMF routing Step 2a
  • 29. www.netgenlabs.com - create Contentful entity, a local proxy for remote Contentful entry (caching and routing purposes) - extend Contentful service to load the Contentful entity - test loading of example Contentful entity - verify new row in the database: 
 mysql phpce -uroot -p -e "select * from orm_routes" - try the route Step 2b
  • 30. www.netgenlabs.com View Controller - create Contentful entity view controller action - configure CMF dynamic router to use it - add content enhancer so the View controller gets the Contentful entity - try the route again Step 3
  • 31. www.netgenlabs.com Netgen Layouts - set private composer repo:
 ”repositories": [ 
 { "type": "composer", "url": "https://packagist.netgen.biz" }
 ], - require “netgen/block-manager” - docs.netgen.io/projects/layouts/en/latest/ reference/install_instructions.html Step 4a
  • 32. www.netgenlabs.com - install needed database tables:
 php bin/console doctrine:migrations:migrate -- configuration=vendor/netgen/block-manager/migrations/ doctrine.yml - install assets:
 php bin/console assets:install --symlink --relative - enable Layouts and configure routing - configure admin access with basic auth Step 4b
  • 33. www.netgenlabs.com - inject Layouts Resolver in Twig templates - create “Home” layout - map that layout to home URL - create shared layout for header and right column Step 4c
  • 34. www.netgenlabs.com Manual item selection with Content Browser - integrate Contentful bundle with ContentBrowser - docs.netgen.io/projects/cb/en/latest/cookbook/ index.html - docs.netgen.io/projects/layouts/en/latest/ cookbook/custom_value_types.html Step 5a
  • 35. www.netgenlabs.com - add Layouts item type for Contentful entity - add ContentBrowser item types for Contentful entity and client - add ContentBrowser backend that browses Contentful entities - add additional ContentBrowser columns for Contentful entity Step 5b
  • 36. www.netgenlabs.com - include bootstrap4 CSS - select products for home grid - add images: {% for image in item.object.getImage() %}
 <img src="{{ image.getFile().getUrl() }}?h=120&w=200"/>
 {% endfor %} - check route table:
 mysql phpce -uroot -p -e "select * from orm_routes" Step 5c
  • 37. www.netgenlabs.com Collection query - docs.netgen.io/projects/layouts/en/latest/ cookbook/custom_query_types.html - add Contentful collection query - configure “latest posts” block Step 6
  • 38. www.netgenlabs.com Layouts Resolver target - docs.netgen.io/projects/layouts/en/latest/ cookbook/custom_target_types.html - add 2 target types, for Contentful entity and space - add Twig extension for target type templates - create a “product” layout and map it Step 7
  • 39. www.netgenlabs.com Layouts Resolver condition - docs.netgen.io/projects/layouts/en/latest/ cookbook/custom_condition_types.html - add Layouts Resolver condition type for Contentful content type - use the condition for “product” layout Step 8
  • 40. www.netgenlabs.com Contentful field block - docs.netgen.io/projects/layouts/en/latest/ cookbook/custom_blocks.html - add Contentful field block type - create a “blog post” layout Step 9
  • 41. www.netgenlabs.com Cache all Contentful entries - finalize sync script - run sync script:
 php bin/console contentful:sync - show debug info Step 10
  • 43. www.netgenlabs.com - just released v0.9 with layout translation capabilities - adding more features (like user policies, ad-hoc content etc.) - launching projects based on Layouts and eZ since end of 2016 - first launches by early adopters (agencies from Germany, Italy) last month, several other starting Currently
  • 44. www.netgenlabs.com - open source the core - make it sustainable with commercial add-ons - integrate tightly with other Symfony based systems - make loose integrations with everything else easy via REST/SOAP, … Future