SlideShare una empresa de Scribd logo
1 de 35
Descargar para leer sin conexión
How we started with eZ Publish 5
A real use case
A cookbook for successful migration from eZ4to theSymfonystack
Ekkehard Dörre - Coolscreen
Donat Fritschy - Webmanufaktur
Presenters
#ezsummer
Ekke is a consultant with deep knowledge in eZ Publish 4 and 5, eZ Find /
Apache Solr and with a faible for coming cutting edge web technologies. He is
one of the organizers of the PHP Unconference since seven years.
Donat is owner of Webmanufaktur, a full service web agency in Switzerland.
He works as projects manager, software architect and developer and likes
thinking outside of the box.
Members of CJW Network
·
·
·
3/35
Why a Cookbook?
#ezsummer
eZ Publish 5 allows for a smooth migration of eZ legacy projects to the
Symfony stack, permitting them to profit from the exiting new possibilities
However, it is a completely new beast
This workshop presents some basic recipes for beginners
·
·
·
4/35
Agenda
Things we'll cover:
#ezsummer
eZ 5 Installation
Building our first Bundle
Overriding the Page Layout Template
Integrating old Templates
Overriding Content Type (formerly Class) Templates
Overriding Field Type (formerly Attribute) Templates
One more thing...
·
·
·
·
·
·
·
5/35
Installation
Prepare the ingredients...
eZ 5 Installation
Recipe #1: Use the installation package
#ezsummer
Use the installation packages from share.ez.no
These are consistent and tested
Everybody knows about what you speak
Forking from GitHub is great, if you want and are able to contribute
·
·
·
·
7/35
eZ 5 Installation
Recipe #2: Read the Installation notes
Common Pitfalls:
#ezsummer
eZ 5 is a complex install and different from what you know
Actually, it combines to environments
https://confluence.ez.no/display/EZP/Requirements
https://confluence.ez.no/display/EZP/Normal+installation
·
·
Symfony
eZ Publish legacy (eZ 4.7)
-
-
·
·
Linking the assets
Directory and file permissions
·
·
8/35
eZ 5 Installation
Recipe #3: Get directory and file permissions right
Strategy 1 (quick and dirty)
Strategy 2
#ezsummer
Same user/group for web server and console user·
Separate users for web server and console user
Both members of www group
Usually requires umask( 0007 )
https://confluence.ez.no/x/9YBx
http://symfony.com/doc/current/book/installation.html#configuration-and-
setup
·
·
·
·
·
9/35
eZ 5 Installation
Recipe #4: Use the setup wizard
#ezsummer
This will give you a testable environment...
... which will immediately show you all problems ;-)
http://ezpublish.ezsc/
http://ezpublish.ezsc/ezdemo_site_admin
Login: admin / Password: ezsc
·
·
·
·
·
10/35
eZ 5 Installation
Recipe #5: The console is you friend
Check out the console command! First, log into the virtual machine using SSH
To list all available commands use
The most important commands:
#ezsummer
$ ssh ezsc@vm.ezsc
ezsc@vm.ezsc''s password: ezsc
$ cd /var/www/ezpublish
BASH
$ php ezpublish/console BASH
$ php ezpublish/console cache:clear
$ php ezpublish/console assets:install
$ php ezpublish/console assetic:dump
$ php ezpublish/console twig:lint
BASH
11/35
Creating Bundles
bring to the boil...
Creating a Bundle
Recipe #6: Use bundles for your sites
A Bundle is similar to an eZ extension and module. We suggest you create separate 'site' bundles for all
sites and 'functional' bundles for common components.
Creation of a bundle is easy:
Follow suggested Namespace conventions: YourCompany/YourCustomer/ComponentBundle
(CjwNetwork/SummerCamp2013/CookBookBundle)
You may define a shorted name for your bundle, as we have: CjwCookBookBundle
Create the Bundle in the src folder and answer yes to all questions.
Note: this will also change ezpublish/EzPublishKernel.php and ezpublish/config/routing.yml to
reference the generated bundle.
#ezsummer
$ php ezpublish/console generate:bundle BASH
13/35
Testing Your Bundle
A generated bundle contains sample code that allows for easy testing:
http://ezpublish.ezsc/hello/demo
The magic is done through a controller which receives the request from the router and prepares a
response with the help of a template renderer.
src/CjwNetwork/SummerCamp2013/CookBookBundle/Controller/DefaultController.php
Note: when implementing your own controllers, follow the code in eZDemoBundle as it includes
additional classes for accessing the repository.
#ezsummer
class DefaultController extends Controller
{
public function indexAction($name)
{
return $this->render('CjwCookBookBundle:Default:index.html.twig', array('name' => $name));
}
}
PHP
14/35
Inspecting the TWIG Template
src/CjwNetwork/SummerCamp2013/CookBookBundle/Resources/views/Default/index.html.twig
We add some formatting and apply a TWIG filter:
#ezsummer
Hello {{ name}} TWIG
<h1>Hello and good morning {{ name | upper }}!</h1> TWIG
http://ezpublish.ezsc/hello/demo
TWIG Doc http://twig.sensiolabs.org/doc/filters/upper.html
·
·
15/35
Adding a Page Layout
Unlike eZ Publish legacy, TWIG templates work “bottom up” and support inheritance.
Therefore it’s easy to show the output in the standard eZ Demo Layout:
src/CjwNetwork/SummerCamp2013/CookBookBundle/Resources/views/Default/index.html.twig
#ezsummer
{# This template extends pagelayout.html.twig and just replaces the 'content' block #}
{% extends "eZDemoBundle::pagelayout.html.twig" %}
{% block content %}
<h1>Hello and good morning {{ name | upper }}!</h1>
{% endblock %}
TWIG
16/35
Overriding Standard Templates
Dish up...
Creating a TWIG Template for Article
src/CjwNetwork/SummerCamp2013/CookBookBundle/Resources/views/full/article.html.twig
#ezsummer
{% extends noLayout ? viewbaseLayout : "eZDemoBundle::pagelayout.html.twig" %}
{% block content %}
{# render a simple field #}
<h3>{{ ez_render_field( content, "title" ) }}</h3>
{# add a class attribute #}
{{ ez_render_field(
content,
"short_title",
{
'attr': { 'class': 'foobar' }
}
) }}
{# add an id to uniquely address this element #}
{{ ez_render_field(
content,
"author",
{
'attr': { 'id': 'authors' }
}
) }}
{{ ez_render_field( content, "intro" ) }}
{{ ez_render_field( content, "body" ) }}
{% endblock %}
TWIG
18/35
Configuration Settings
Recipe #7: Define Settings in your Bundle using Prepend
Besides the global configuration settings in ezpublish/config/ezpublish.yml there are other
possibilities to define settings:
https://confluence.ez.no/display/EZP/Import+settings+from+a+bundle
We prefer the one which allows the settings to be “prepended” to the normal settings, as no changes to
the global settings are needed.
Note: when implementing your own controllers, follow the code in eZDemoBundle as it includes
additional classes for accessing the repository.
#ezsummer 19/35
Configuration Settings
Recipe #7: Define Settings in your Bundle using Prepend
src/CjwNetwork/SummerCamp2013/CookBookBundle/DependencyInjection/CjwCookBookExtension.php
#ezsummer
use SymfonyComponentDependencyInjectionContainerBuilder;
use SymfonyComponentConfigFileLocator;
use SymfonyComponentDependencyInjectionExtensionPrependExtensionInterface;
use SymfonyComponentHttpKernelDependencyInjectionExtension;
use SymfonyComponentDependencyInjectionLoader;
use SymfonyComponentYamlYaml;
class CjwCookBookExtension extends Extension implements PrependExtensionInterface
public function prepend( ContainerBuilder $container )
{
// Loading our YAML file containing our template rules
$config = Yaml::parse( __DIR__ . '/../Resources/config/override.yml' );
// We explicitly prepend loaded configuration for "ezpublish" namespace.
// So it will be placed under the "ezpublish" configuration key, like in ezpublish.yml.
$container->prependExtensionConfig( 'ezpublish', $config );
}
PHP
20/35
Override Settings
src/CjwNetwork/SummerCamp2013/CookBookBundle/Resources/config/override.yml
#ezsummer
# We explicitly prepend config for "ezpublish" namespace in service container extension,
# so no need to repeat it here
system:
ezdemo_site:
location_view:
full:
article_test:
template: "CjwCookBookBundle:full:article.html.twig"
match:
IdentifierContentType: article
YML
21/35
Change the Field Type Template ezauthor …
src/CjwNetwork/SummerCamp2013/CookBookBundle/Resources/views/fields/field_templates.html.twig
#ezsummer
{# you must inherit from this template in order to use the block() functions !#}
{% extends "EzPublishCoreBundle::content_fields.html.twig" %}
{% block ezauthor_field %}
{% spaceless %}
{% if field.value.authors|length() > 0 %}
<ul {{ block( 'field_attributes' ) }}>
{% for author in field.value.authors %}
<li><a href="mailto:{{ author.email|escape( 'url' ) }}">xx {{ author.name }} xx</a></li>
{% endfor %}
</ul>
{% endif %}
{% endspaceless %}
{% endblock %}
TWIG
22/35
… and the Field Type Template ezdatetime
src/CjwNetwork/SummerCamp2013/CookBookBundle/Resources/views/fields/field_templates.html.twig
#ezsummer
{% block ezdatetime_field %}
{% spaceless %}
{% if field.value.value %}
{% if fieldSettings.useSeconds %}
{% set field_value = field.value.value|localizeddate( 'short', 'medium', parameters.locale ) %}
{% else %}
{% set field_value = field.value.value|localizeddate( 'short', 'short', parameters.locale ) %}
{% endif %}
xx {{ block( 'simple_block_field' ) }} xx
{% endif %}
{% endspaceless %}
{% endblock %}
TWIG
23/35
Override Settings for Field Types
src/CjwNetwork/SummerCamp2013/CookBookBundle/Resources/config/override.yml
#ezsummer
# We explicitly prepend config for "ezpublish" namespace in service container extension,
# so no need to repeat it here
system:
ezdemo_site:
location_view:
full:
article_test:
template: "CjwCookBookBundle:full:article.html.twig"
match:
IdentifierContentType: article
field_templates:
-
template: "CjwCookBookBundle:fields:field_templates.html.twig"
# Priority is optional (default is 0). The higher it is, the higher your template gets in the list.
priority: 10
YML
24/35
A Brand New Page Layout
… and enjoy!
Adding a New Page Layout for Our TWIG Article
We have prepared a brand new page layout in our bundle. You can find it at
src/CjwNetwork/SummerCamp2013/CookBookBundle/Resources/views/pagelayout.html.twig
To use it, change
src/CjwNetwork/SummerCamp2013/CookBookBundle/Resources/views/full/article.html.twig
to reference it:
Now articles (only!) are shown using the new page layout.
Note: to set the page layout for all your site, adjust the settings in ezpublish/config/parameters.yml
#ezsummer
{% extends noLayout ? viewbaseLayout : "CjwCookBookBundle::pagelayout.html.twig" %} TWIG
26/35
Some More Goodies
any sweets?
Set the Missing HTML Title
In eZDemoBundle the page title is not correctly set. {{ title|default( 'Home' ) }} is empty, so we
need to set it. We look for the legacy path, then for new eZ Publish content and the for our own bundle.
src/CjwNetwork/SummerCamp2013/CookBookBundle/Resources/views/pagelayout.html.twig
https://confluence.ez.no/display/EZP/Twig+Helper
#ezsummer
{% if ezpublish.legacy.has( 'path' ) %}
{% set path = ezpublish.legacy.get( 'path' ) %}
{% set title %}
CJW Network {% for pathitem in path|reverse %} / {{ pathitem.text }}{% endfor %}
{% endset %}
{% elseif content is defined%}
{% set title %}
CJW Network / {{ content.contentInfo.name }} / (location ID is #{{ location.id }})
{% endset %}
{% else %}
{% set title %}
CJW Network / {{ name | capitalize }}
{% endset %}
{% endif %}
TWIG
28/35
Include an Old eZ Publish Template (.tpl)
To include an old eZ Template, e.g.
ezpublish_legacy/extension/ezdemo/design/ezdemo/templates/footer/latest_news.tpl into your
TWIG page layout, use the following code:
src/CjwNetwork/SummerCamp2013/CookBookBundle/Resources/views/pagelayout.html.twig
#ezsummer
{% block latest_news %}
{% include "design:footer/latest_news.tpl" %}
{% endblock %}
TWIG
29/35
Include an Old eZ Publish Template (.tpl)
You can also pass parameters to an old template: change the fetch in
ezpublish_legacy/extension/ezdemo/design/ezdemo/templates/footer/latest_news.tpl
to ( 'content', 'tree', hash( 'parent_node_id', $parent_node_id, … )
and set the variable {$parent_node_id} in your TWIG page layout
src/CjwNetwork/SummerCamp2013/CookBookBundle/Resources/views/pagelayout.html.twig
#ezsummer
{% block latest_news %}
{% include "design:footer/latest_news.tpl" with {"parent_node_id": 2} %}
{% endblock %}
TWIG
30/35
Override Several Blocks of the Page Layout
You can override several blocks of the TWIG page layout in a template that inherits from it.
src/CjwNetwork/SummerCamp2013/CookBookBundle/Resources/views/full/article.html.twig
https://confluence.ez.no/display/EZP/Legacy+code+and+features#Legacycodeandfeatures-
LegacyTemplateinclusion
#ezsummer
{% block latest_news %}
We set the content here for the latest_news block in our page layout
{% endblock %}
{% block content %}
...
{% endblock %}
TWIG
31/35
One More Thing...
Globally Overriding Resources!
Recipe #8: Override resources from bundles using the
ezpublish/Resource folder
Symfony allows for globally overrides of resources. You can teach eZ Publish the
same trick!
Suppose you want to override the eZDemo page layout:
#ezsummer
In the ezpublish folder, create a Resources folder
Replicate the directory structure for the elements you want to override
e.g. Resources/eZDemoBundle/views - use the correct bundle name!!!
Place your files there
·
·
·
·
33/35
Resources
To install our cookbook
Find the slides and the bash script to recreate the steps in
CjwNetwork/SummerCamp2013/CookBookBundle/Resources/doc
#ezsummer
cd /src
git clone https://github.com/dfritschy/cjw-cookbook.git CjwNetwork
BASH
34/35
<Thank You!>
Ekkehard Dörre
http://share.ez.no/community/profile/7431
@ekkeD
http://www.coolscreen.de
Donat Fritschy
https://github.com/dfritschy
http://share.ez.no/community/profile/10451
@webmanufaktur
http://www.webmanufaktur.ch

Más contenido relacionado

La actualidad más candente

Ezobject wrapper workshop
Ezobject wrapper workshopEzobject wrapper workshop
Ezobject wrapper workshopKaliop-slide
 
Symfony and eZ Publish: boarding now!
Symfony and eZ Publish: boarding now!Symfony and eZ Publish: boarding now!
Symfony and eZ Publish: boarding now!Nicolas Pastorino
 
Ansible + WordPress
Ansible + WordPressAnsible + WordPress
Ansible + WordPressAlan Lok
 
6 Years of Docker: The Good, the Bad and Python Packaging at PyCon.DE&PyData ...
6 Years of Docker: The Good, the Bad and Python Packaging at PyCon.DE&PyData ...6 Years of Docker: The Good, the Bad and Python Packaging at PyCon.DE&PyData ...
6 Years of Docker: The Good, the Bad and Python Packaging at PyCon.DE&PyData ...Sebastian Neubauer
 
Stress Free Deployment - Confoo 2011
Stress Free Deployment  - Confoo 2011Stress Free Deployment  - Confoo 2011
Stress Free Deployment - Confoo 2011Bachkoutou Toutou
 
Setting up your Multi Engine Environment - Apache Railo and ColdFusion
Setting up your Multi Engine Environment - Apache Railo and ColdFusionSetting up your Multi Engine Environment - Apache Railo and ColdFusion
Setting up your Multi Engine Environment - Apache Railo and ColdFusionGavin Pickin
 
Ansible automation tool with modules
Ansible automation tool with modulesAnsible automation tool with modules
Ansible automation tool with modulesmohamedmoharam
 
Puppet for SysAdmins
Puppet for SysAdminsPuppet for SysAdmins
Puppet for SysAdminsPuppet
 
Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...
Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...
Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...Alexander Lisachenko
 
Vagrant for real (codemotion rome 2016)
Vagrant for real (codemotion rome 2016)Vagrant for real (codemotion rome 2016)
Vagrant for real (codemotion rome 2016)Michele Orselli
 
Docker presentasjon java bin
Docker presentasjon java binDocker presentasjon java bin
Docker presentasjon java binOlve Hansen
 
Virtual CD4PE Workshop
Virtual CD4PE WorkshopVirtual CD4PE Workshop
Virtual CD4PE WorkshopPuppet
 
Learn Puppet : Quest Guide for the Learning VM
Learn Puppet : Quest Guide for the Learning VMLearn Puppet : Quest Guide for the Learning VM
Learn Puppet : Quest Guide for the Learning VMKumaran Balachandran
 
Symfony4 - Deep dive
Symfony4 - Deep diveSymfony4 - Deep dive
Symfony4 - Deep diveSalma Ghareeb
 
How to deploy PHP projects with docker
How to deploy PHP projects with dockerHow to deploy PHP projects with docker
How to deploy PHP projects with dockerRuoshi Ling
 
Debugging webOS applications
Debugging webOS applicationsDebugging webOS applications
Debugging webOS applicationsfpatton
 
Create your own composer package
Create your own composer packageCreate your own composer package
Create your own composer packageLattapon Yodsuwan
 
Performance tips for Symfony2 & PHP
Performance tips for Symfony2 & PHPPerformance tips for Symfony2 & PHP
Performance tips for Symfony2 & PHPMax Romanovsky
 
Create Development and Production Environments with Vagrant
Create Development and Production Environments with VagrantCreate Development and Production Environments with Vagrant
Create Development and Production Environments with VagrantBrian Hogan
 

La actualidad más candente (20)

Ezobject wrapper workshop
Ezobject wrapper workshopEzobject wrapper workshop
Ezobject wrapper workshop
 
Ansible 2.2
Ansible 2.2Ansible 2.2
Ansible 2.2
 
Symfony and eZ Publish: boarding now!
Symfony and eZ Publish: boarding now!Symfony and eZ Publish: boarding now!
Symfony and eZ Publish: boarding now!
 
Ansible + WordPress
Ansible + WordPressAnsible + WordPress
Ansible + WordPress
 
6 Years of Docker: The Good, the Bad and Python Packaging at PyCon.DE&PyData ...
6 Years of Docker: The Good, the Bad and Python Packaging at PyCon.DE&PyData ...6 Years of Docker: The Good, the Bad and Python Packaging at PyCon.DE&PyData ...
6 Years of Docker: The Good, the Bad and Python Packaging at PyCon.DE&PyData ...
 
Stress Free Deployment - Confoo 2011
Stress Free Deployment  - Confoo 2011Stress Free Deployment  - Confoo 2011
Stress Free Deployment - Confoo 2011
 
Setting up your Multi Engine Environment - Apache Railo and ColdFusion
Setting up your Multi Engine Environment - Apache Railo and ColdFusionSetting up your Multi Engine Environment - Apache Railo and ColdFusion
Setting up your Multi Engine Environment - Apache Railo and ColdFusion
 
Ansible automation tool with modules
Ansible automation tool with modulesAnsible automation tool with modules
Ansible automation tool with modules
 
Puppet for SysAdmins
Puppet for SysAdminsPuppet for SysAdmins
Puppet for SysAdmins
 
Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...
Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...
Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...
 
Vagrant for real (codemotion rome 2016)
Vagrant for real (codemotion rome 2016)Vagrant for real (codemotion rome 2016)
Vagrant for real (codemotion rome 2016)
 
Docker presentasjon java bin
Docker presentasjon java binDocker presentasjon java bin
Docker presentasjon java bin
 
Virtual CD4PE Workshop
Virtual CD4PE WorkshopVirtual CD4PE Workshop
Virtual CD4PE Workshop
 
Learn Puppet : Quest Guide for the Learning VM
Learn Puppet : Quest Guide for the Learning VMLearn Puppet : Quest Guide for the Learning VM
Learn Puppet : Quest Guide for the Learning VM
 
Symfony4 - Deep dive
Symfony4 - Deep diveSymfony4 - Deep dive
Symfony4 - Deep dive
 
How to deploy PHP projects with docker
How to deploy PHP projects with dockerHow to deploy PHP projects with docker
How to deploy PHP projects with docker
 
Debugging webOS applications
Debugging webOS applicationsDebugging webOS applications
Debugging webOS applications
 
Create your own composer package
Create your own composer packageCreate your own composer package
Create your own composer package
 
Performance tips for Symfony2 & PHP
Performance tips for Symfony2 & PHPPerformance tips for Symfony2 & PHP
Performance tips for Symfony2 & PHP
 
Create Development and Production Environments with Vagrant
Create Development and Production Environments with VagrantCreate Development and Production Environments with Vagrant
Create Development and Production Environments with Vagrant
 

Similar a How we Started with eZ publish 5 a Real Use Case

Getting instantly up and running with Docker and Symfony
Getting instantly up and running with Docker and SymfonyGetting instantly up and running with Docker and Symfony
Getting instantly up and running with Docker and SymfonyAndré Rømcke
 
EmacsConf 2019: Interactive Remote Debugging and Development with TRAMP Mode
EmacsConf 2019: Interactive Remote Debugging and Development with TRAMP ModeEmacsConf 2019: Interactive Remote Debugging and Development with TRAMP Mode
EmacsConf 2019: Interactive Remote Debugging and Development with TRAMP ModeMatt Ray
 
eZ Platform Cloud and eZ Launchpad: Don’t Host, Don’t Deploy, Don’t Install—J...
eZ Platform Cloud and eZ Launchpad: Don’t Host, Don’t Deploy, Don’t Install—J...eZ Platform Cloud and eZ Launchpad: Don’t Host, Don’t Deploy, Don’t Install—J...
eZ Platform Cloud and eZ Launchpad: Don’t Host, Don’t Deploy, Don’t Install—J...eZ Systems
 
eZ Platform Cloud and eZ Launchpad: Don’t Host, Don’t Deploy, Don’t Install—J...
eZ Platform Cloud and eZ Launchpad: Don’t Host, Don’t Deploy, Don’t Install—J...eZ Platform Cloud and eZ Launchpad: Don’t Host, Don’t Deploy, Don’t Install—J...
eZ Platform Cloud and eZ Launchpad: Don’t Host, Don’t Deploy, Don’t Install—J...Sébastien Morel
 
Automate with Ansible basic (2/e, English)
Automate with Ansible basic (2/e, English)Automate with Ansible basic (2/e, English)
Automate with Ansible basic (2/e, English)Chu-Siang Lai
 
Symfony finally swiped right on envvars
Symfony finally swiped right on envvarsSymfony finally swiped right on envvars
Symfony finally swiped right on envvarsSam Marley-Jarrett
 
Cloud Automation with Opscode Chef
Cloud Automation with Opscode ChefCloud Automation with Opscode Chef
Cloud Automation with Opscode ChefSri Ram
 
DEV Čtvrtkon #76 - Makefile
DEV Čtvrtkon #76 - MakefileDEV Čtvrtkon #76 - Makefile
DEV Čtvrtkon #76 - MakefileCtvrtkoncz
 
Creating a full stack web app with python, npm, webpack and react
Creating a full stack web app with python, npm, webpack and reactCreating a full stack web app with python, npm, webpack and react
Creating a full stack web app with python, npm, webpack and reactAngela Kristine Juvet Branaes
 
Enabling Hybrid Workflows with Docker/Mesos @Orbitz
Enabling Hybrid Workflows with Docker/Mesos @OrbitzEnabling Hybrid Workflows with Docker/Mesos @Orbitz
Enabling Hybrid Workflows with Docker/Mesos @OrbitzSteve Hoffman
 
Ansible new paradigms for orchestration
Ansible new paradigms for orchestrationAnsible new paradigms for orchestration
Ansible new paradigms for orchestrationPaolo Tonin
 
Improve your Java Environment with Docker
Improve your Java Environment with DockerImprove your Java Environment with Docker
Improve your Java Environment with DockerHanoiJUG
 
Twig for Drupal 8 and PHP | Presented at OC Drupal
Twig for Drupal 8 and PHP | Presented at OC DrupalTwig for Drupal 8 and PHP | Presented at OC Drupal
Twig for Drupal 8 and PHP | Presented at OC Drupalwebbywe
 
20130528 solution linux_frousseau_nopain_webdev
20130528 solution linux_frousseau_nopain_webdev20130528 solution linux_frousseau_nopain_webdev
20130528 solution linux_frousseau_nopain_webdevFrank Rousseau
 
Intro To Node.js
Intro To Node.jsIntro To Node.js
Intro To Node.jsChris Cowan
 
How to create your own hack environment
How to create your own hack environmentHow to create your own hack environment
How to create your own hack environmentSumedt Jitpukdebodin
 
Cloud Automation with Opscode Chef
Cloud Automation with Opscode ChefCloud Automation with Opscode Chef
Cloud Automation with Opscode ChefSri Ram
 
Buildout: How to maintain big app stacks without losing your mind
Buildout: How to maintain big app stacks without losing your mindBuildout: How to maintain big app stacks without losing your mind
Buildout: How to maintain big app stacks without losing your mindDylan Jay
 

Similar a How we Started with eZ publish 5 a Real Use Case (20)

Getting instantly up and running with Docker and Symfony
Getting instantly up and running with Docker and SymfonyGetting instantly up and running with Docker and Symfony
Getting instantly up and running with Docker and Symfony
 
EmacsConf 2019: Interactive Remote Debugging and Development with TRAMP Mode
EmacsConf 2019: Interactive Remote Debugging and Development with TRAMP ModeEmacsConf 2019: Interactive Remote Debugging and Development with TRAMP Mode
EmacsConf 2019: Interactive Remote Debugging and Development with TRAMP Mode
 
eZ Platform Cloud and eZ Launchpad: Don’t Host, Don’t Deploy, Don’t Install—J...
eZ Platform Cloud and eZ Launchpad: Don’t Host, Don’t Deploy, Don’t Install—J...eZ Platform Cloud and eZ Launchpad: Don’t Host, Don’t Deploy, Don’t Install—J...
eZ Platform Cloud and eZ Launchpad: Don’t Host, Don’t Deploy, Don’t Install—J...
 
eZ Platform Cloud and eZ Launchpad: Don’t Host, Don’t Deploy, Don’t Install—J...
eZ Platform Cloud and eZ Launchpad: Don’t Host, Don’t Deploy, Don’t Install—J...eZ Platform Cloud and eZ Launchpad: Don’t Host, Don’t Deploy, Don’t Install—J...
eZ Platform Cloud and eZ Launchpad: Don’t Host, Don’t Deploy, Don’t Install—J...
 
Automate with Ansible basic (2/e, English)
Automate with Ansible basic (2/e, English)Automate with Ansible basic (2/e, English)
Automate with Ansible basic (2/e, English)
 
Symfony finally swiped right on envvars
Symfony finally swiped right on envvarsSymfony finally swiped right on envvars
Symfony finally swiped right on envvars
 
Cloud Automation with Opscode Chef
Cloud Automation with Opscode ChefCloud Automation with Opscode Chef
Cloud Automation with Opscode Chef
 
DEV Čtvrtkon #76 - Makefile
DEV Čtvrtkon #76 - MakefileDEV Čtvrtkon #76 - Makefile
DEV Čtvrtkon #76 - Makefile
 
Commcon 2018
Commcon 2018Commcon 2018
Commcon 2018
 
Creating a full stack web app with python, npm, webpack and react
Creating a full stack web app with python, npm, webpack and reactCreating a full stack web app with python, npm, webpack and react
Creating a full stack web app with python, npm, webpack and react
 
Enabling Hybrid Workflows with Docker/Mesos @Orbitz
Enabling Hybrid Workflows with Docker/Mesos @OrbitzEnabling Hybrid Workflows with Docker/Mesos @Orbitz
Enabling Hybrid Workflows with Docker/Mesos @Orbitz
 
Ansible new paradigms for orchestration
Ansible new paradigms for orchestrationAnsible new paradigms for orchestration
Ansible new paradigms for orchestration
 
Improve your Java Environment with Docker
Improve your Java Environment with DockerImprove your Java Environment with Docker
Improve your Java Environment with Docker
 
Twig for Drupal 8 and PHP | Presented at OC Drupal
Twig for Drupal 8 and PHP | Presented at OC DrupalTwig for Drupal 8 and PHP | Presented at OC Drupal
Twig for Drupal 8 and PHP | Presented at OC Drupal
 
Pyramid deployment
Pyramid deploymentPyramid deployment
Pyramid deployment
 
20130528 solution linux_frousseau_nopain_webdev
20130528 solution linux_frousseau_nopain_webdev20130528 solution linux_frousseau_nopain_webdev
20130528 solution linux_frousseau_nopain_webdev
 
Intro To Node.js
Intro To Node.jsIntro To Node.js
Intro To Node.js
 
How to create your own hack environment
How to create your own hack environmentHow to create your own hack environment
How to create your own hack environment
 
Cloud Automation with Opscode Chef
Cloud Automation with Opscode ChefCloud Automation with Opscode Chef
Cloud Automation with Opscode Chef
 
Buildout: How to maintain big app stacks without losing your mind
Buildout: How to maintain big app stacks without losing your mindBuildout: How to maintain big app stacks without losing your mind
Buildout: How to maintain big app stacks without losing your mind
 

Último

Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 

Último (20)

Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 

How we Started with eZ publish 5 a Real Use Case

  • 1.
  • 2. How we started with eZ Publish 5 A real use case A cookbook for successful migration from eZ4to theSymfonystack Ekkehard Dörre - Coolscreen Donat Fritschy - Webmanufaktur
  • 3. Presenters #ezsummer Ekke is a consultant with deep knowledge in eZ Publish 4 and 5, eZ Find / Apache Solr and with a faible for coming cutting edge web technologies. He is one of the organizers of the PHP Unconference since seven years. Donat is owner of Webmanufaktur, a full service web agency in Switzerland. He works as projects manager, software architect and developer and likes thinking outside of the box. Members of CJW Network · · · 3/35
  • 4. Why a Cookbook? #ezsummer eZ Publish 5 allows for a smooth migration of eZ legacy projects to the Symfony stack, permitting them to profit from the exiting new possibilities However, it is a completely new beast This workshop presents some basic recipes for beginners · · · 4/35
  • 5. Agenda Things we'll cover: #ezsummer eZ 5 Installation Building our first Bundle Overriding the Page Layout Template Integrating old Templates Overriding Content Type (formerly Class) Templates Overriding Field Type (formerly Attribute) Templates One more thing... · · · · · · · 5/35
  • 7. eZ 5 Installation Recipe #1: Use the installation package #ezsummer Use the installation packages from share.ez.no These are consistent and tested Everybody knows about what you speak Forking from GitHub is great, if you want and are able to contribute · · · · 7/35
  • 8. eZ 5 Installation Recipe #2: Read the Installation notes Common Pitfalls: #ezsummer eZ 5 is a complex install and different from what you know Actually, it combines to environments https://confluence.ez.no/display/EZP/Requirements https://confluence.ez.no/display/EZP/Normal+installation · · Symfony eZ Publish legacy (eZ 4.7) - - · · Linking the assets Directory and file permissions · · 8/35
  • 9. eZ 5 Installation Recipe #3: Get directory and file permissions right Strategy 1 (quick and dirty) Strategy 2 #ezsummer Same user/group for web server and console user· Separate users for web server and console user Both members of www group Usually requires umask( 0007 ) https://confluence.ez.no/x/9YBx http://symfony.com/doc/current/book/installation.html#configuration-and- setup · · · · · 9/35
  • 10. eZ 5 Installation Recipe #4: Use the setup wizard #ezsummer This will give you a testable environment... ... which will immediately show you all problems ;-) http://ezpublish.ezsc/ http://ezpublish.ezsc/ezdemo_site_admin Login: admin / Password: ezsc · · · · · 10/35
  • 11. eZ 5 Installation Recipe #5: The console is you friend Check out the console command! First, log into the virtual machine using SSH To list all available commands use The most important commands: #ezsummer $ ssh ezsc@vm.ezsc ezsc@vm.ezsc''s password: ezsc $ cd /var/www/ezpublish BASH $ php ezpublish/console BASH $ php ezpublish/console cache:clear $ php ezpublish/console assets:install $ php ezpublish/console assetic:dump $ php ezpublish/console twig:lint BASH 11/35
  • 13. Creating a Bundle Recipe #6: Use bundles for your sites A Bundle is similar to an eZ extension and module. We suggest you create separate 'site' bundles for all sites and 'functional' bundles for common components. Creation of a bundle is easy: Follow suggested Namespace conventions: YourCompany/YourCustomer/ComponentBundle (CjwNetwork/SummerCamp2013/CookBookBundle) You may define a shorted name for your bundle, as we have: CjwCookBookBundle Create the Bundle in the src folder and answer yes to all questions. Note: this will also change ezpublish/EzPublishKernel.php and ezpublish/config/routing.yml to reference the generated bundle. #ezsummer $ php ezpublish/console generate:bundle BASH 13/35
  • 14. Testing Your Bundle A generated bundle contains sample code that allows for easy testing: http://ezpublish.ezsc/hello/demo The magic is done through a controller which receives the request from the router and prepares a response with the help of a template renderer. src/CjwNetwork/SummerCamp2013/CookBookBundle/Controller/DefaultController.php Note: when implementing your own controllers, follow the code in eZDemoBundle as it includes additional classes for accessing the repository. #ezsummer class DefaultController extends Controller { public function indexAction($name) { return $this->render('CjwCookBookBundle:Default:index.html.twig', array('name' => $name)); } } PHP 14/35
  • 15. Inspecting the TWIG Template src/CjwNetwork/SummerCamp2013/CookBookBundle/Resources/views/Default/index.html.twig We add some formatting and apply a TWIG filter: #ezsummer Hello {{ name}} TWIG <h1>Hello and good morning {{ name | upper }}!</h1> TWIG http://ezpublish.ezsc/hello/demo TWIG Doc http://twig.sensiolabs.org/doc/filters/upper.html · · 15/35
  • 16. Adding a Page Layout Unlike eZ Publish legacy, TWIG templates work “bottom up” and support inheritance. Therefore it’s easy to show the output in the standard eZ Demo Layout: src/CjwNetwork/SummerCamp2013/CookBookBundle/Resources/views/Default/index.html.twig #ezsummer {# This template extends pagelayout.html.twig and just replaces the 'content' block #} {% extends "eZDemoBundle::pagelayout.html.twig" %} {% block content %} <h1>Hello and good morning {{ name | upper }}!</h1> {% endblock %} TWIG 16/35
  • 18. Creating a TWIG Template for Article src/CjwNetwork/SummerCamp2013/CookBookBundle/Resources/views/full/article.html.twig #ezsummer {% extends noLayout ? viewbaseLayout : "eZDemoBundle::pagelayout.html.twig" %} {% block content %} {# render a simple field #} <h3>{{ ez_render_field( content, "title" ) }}</h3> {# add a class attribute #} {{ ez_render_field( content, "short_title", { 'attr': { 'class': 'foobar' } } ) }} {# add an id to uniquely address this element #} {{ ez_render_field( content, "author", { 'attr': { 'id': 'authors' } } ) }} {{ ez_render_field( content, "intro" ) }} {{ ez_render_field( content, "body" ) }} {% endblock %} TWIG 18/35
  • 19. Configuration Settings Recipe #7: Define Settings in your Bundle using Prepend Besides the global configuration settings in ezpublish/config/ezpublish.yml there are other possibilities to define settings: https://confluence.ez.no/display/EZP/Import+settings+from+a+bundle We prefer the one which allows the settings to be “prepended” to the normal settings, as no changes to the global settings are needed. Note: when implementing your own controllers, follow the code in eZDemoBundle as it includes additional classes for accessing the repository. #ezsummer 19/35
  • 20. Configuration Settings Recipe #7: Define Settings in your Bundle using Prepend src/CjwNetwork/SummerCamp2013/CookBookBundle/DependencyInjection/CjwCookBookExtension.php #ezsummer use SymfonyComponentDependencyInjectionContainerBuilder; use SymfonyComponentConfigFileLocator; use SymfonyComponentDependencyInjectionExtensionPrependExtensionInterface; use SymfonyComponentHttpKernelDependencyInjectionExtension; use SymfonyComponentDependencyInjectionLoader; use SymfonyComponentYamlYaml; class CjwCookBookExtension extends Extension implements PrependExtensionInterface public function prepend( ContainerBuilder $container ) { // Loading our YAML file containing our template rules $config = Yaml::parse( __DIR__ . '/../Resources/config/override.yml' ); // We explicitly prepend loaded configuration for "ezpublish" namespace. // So it will be placed under the "ezpublish" configuration key, like in ezpublish.yml. $container->prependExtensionConfig( 'ezpublish', $config ); } PHP 20/35
  • 21. Override Settings src/CjwNetwork/SummerCamp2013/CookBookBundle/Resources/config/override.yml #ezsummer # We explicitly prepend config for "ezpublish" namespace in service container extension, # so no need to repeat it here system: ezdemo_site: location_view: full: article_test: template: "CjwCookBookBundle:full:article.html.twig" match: IdentifierContentType: article YML 21/35
  • 22. Change the Field Type Template ezauthor … src/CjwNetwork/SummerCamp2013/CookBookBundle/Resources/views/fields/field_templates.html.twig #ezsummer {# you must inherit from this template in order to use the block() functions !#} {% extends "EzPublishCoreBundle::content_fields.html.twig" %} {% block ezauthor_field %} {% spaceless %} {% if field.value.authors|length() > 0 %} <ul {{ block( 'field_attributes' ) }}> {% for author in field.value.authors %} <li><a href="mailto:{{ author.email|escape( 'url' ) }}">xx {{ author.name }} xx</a></li> {% endfor %} </ul> {% endif %} {% endspaceless %} {% endblock %} TWIG 22/35
  • 23. … and the Field Type Template ezdatetime src/CjwNetwork/SummerCamp2013/CookBookBundle/Resources/views/fields/field_templates.html.twig #ezsummer {% block ezdatetime_field %} {% spaceless %} {% if field.value.value %} {% if fieldSettings.useSeconds %} {% set field_value = field.value.value|localizeddate( 'short', 'medium', parameters.locale ) %} {% else %} {% set field_value = field.value.value|localizeddate( 'short', 'short', parameters.locale ) %} {% endif %} xx {{ block( 'simple_block_field' ) }} xx {% endif %} {% endspaceless %} {% endblock %} TWIG 23/35
  • 24. Override Settings for Field Types src/CjwNetwork/SummerCamp2013/CookBookBundle/Resources/config/override.yml #ezsummer # We explicitly prepend config for "ezpublish" namespace in service container extension, # so no need to repeat it here system: ezdemo_site: location_view: full: article_test: template: "CjwCookBookBundle:full:article.html.twig" match: IdentifierContentType: article field_templates: - template: "CjwCookBookBundle:fields:field_templates.html.twig" # Priority is optional (default is 0). The higher it is, the higher your template gets in the list. priority: 10 YML 24/35
  • 25. A Brand New Page Layout … and enjoy!
  • 26. Adding a New Page Layout for Our TWIG Article We have prepared a brand new page layout in our bundle. You can find it at src/CjwNetwork/SummerCamp2013/CookBookBundle/Resources/views/pagelayout.html.twig To use it, change src/CjwNetwork/SummerCamp2013/CookBookBundle/Resources/views/full/article.html.twig to reference it: Now articles (only!) are shown using the new page layout. Note: to set the page layout for all your site, adjust the settings in ezpublish/config/parameters.yml #ezsummer {% extends noLayout ? viewbaseLayout : "CjwCookBookBundle::pagelayout.html.twig" %} TWIG 26/35
  • 28. Set the Missing HTML Title In eZDemoBundle the page title is not correctly set. {{ title|default( 'Home' ) }} is empty, so we need to set it. We look for the legacy path, then for new eZ Publish content and the for our own bundle. src/CjwNetwork/SummerCamp2013/CookBookBundle/Resources/views/pagelayout.html.twig https://confluence.ez.no/display/EZP/Twig+Helper #ezsummer {% if ezpublish.legacy.has( 'path' ) %} {% set path = ezpublish.legacy.get( 'path' ) %} {% set title %} CJW Network {% for pathitem in path|reverse %} / {{ pathitem.text }}{% endfor %} {% endset %} {% elseif content is defined%} {% set title %} CJW Network / {{ content.contentInfo.name }} / (location ID is #{{ location.id }}) {% endset %} {% else %} {% set title %} CJW Network / {{ name | capitalize }} {% endset %} {% endif %} TWIG 28/35
  • 29. Include an Old eZ Publish Template (.tpl) To include an old eZ Template, e.g. ezpublish_legacy/extension/ezdemo/design/ezdemo/templates/footer/latest_news.tpl into your TWIG page layout, use the following code: src/CjwNetwork/SummerCamp2013/CookBookBundle/Resources/views/pagelayout.html.twig #ezsummer {% block latest_news %} {% include "design:footer/latest_news.tpl" %} {% endblock %} TWIG 29/35
  • 30. Include an Old eZ Publish Template (.tpl) You can also pass parameters to an old template: change the fetch in ezpublish_legacy/extension/ezdemo/design/ezdemo/templates/footer/latest_news.tpl to ( 'content', 'tree', hash( 'parent_node_id', $parent_node_id, … ) and set the variable {$parent_node_id} in your TWIG page layout src/CjwNetwork/SummerCamp2013/CookBookBundle/Resources/views/pagelayout.html.twig #ezsummer {% block latest_news %} {% include "design:footer/latest_news.tpl" with {"parent_node_id": 2} %} {% endblock %} TWIG 30/35
  • 31. Override Several Blocks of the Page Layout You can override several blocks of the TWIG page layout in a template that inherits from it. src/CjwNetwork/SummerCamp2013/CookBookBundle/Resources/views/full/article.html.twig https://confluence.ez.no/display/EZP/Legacy+code+and+features#Legacycodeandfeatures- LegacyTemplateinclusion #ezsummer {% block latest_news %} We set the content here for the latest_news block in our page layout {% endblock %} {% block content %} ... {% endblock %} TWIG 31/35
  • 33. Globally Overriding Resources! Recipe #8: Override resources from bundles using the ezpublish/Resource folder Symfony allows for globally overrides of resources. You can teach eZ Publish the same trick! Suppose you want to override the eZDemo page layout: #ezsummer In the ezpublish folder, create a Resources folder Replicate the directory structure for the elements you want to override e.g. Resources/eZDemoBundle/views - use the correct bundle name!!! Place your files there · · · · 33/35
  • 34. Resources To install our cookbook Find the slides and the bash script to recreate the steps in CjwNetwork/SummerCamp2013/CookBookBundle/Resources/doc #ezsummer cd /src git clone https://github.com/dfritschy/cjw-cookbook.git CjwNetwork BASH 34/35
  • 35. <Thank You!> Ekkehard Dörre http://share.ez.no/community/profile/7431 @ekkeD http://www.coolscreen.de Donat Fritschy https://github.com/dfritschy http://share.ez.no/community/profile/10451 @webmanufaktur http://www.webmanufaktur.ch