SlideShare ist ein Scribd-Unternehmen logo
1 von 35
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Was ist angesagt?

Taking the Friction Out of Ticket Investigation (Standardized Debugging Envir...
Taking the Friction Out of Ticket Investigation (Standardized Debugging Envir...Taking the Friction Out of Ticket Investigation (Standardized Debugging Envir...
Taking the Friction Out of Ticket Investigation (Standardized Debugging Envir...Atlassian
 
Contributing to WordPress Core - Peter Wilson
Contributing to WordPress Core - Peter WilsonContributing to WordPress Core - Peter Wilson
Contributing to WordPress Core - Peter WilsonWordCamp Sydney
 
Automatisation in development and testing - within budget
Automatisation in development and testing - within budgetAutomatisation in development and testing - within budget
Automatisation in development and testing - within budgetDavid Lukac
 
Microservice Teststrategie mit Symfony2
Microservice Teststrategie mit Symfony2Microservice Teststrategie mit Symfony2
Microservice Teststrategie mit Symfony2Per Bernhardt
 
WordPress mit Composer und Git verwalten
WordPress mit Composer und Git verwaltenWordPress mit Composer und Git verwalten
WordPress mit Composer und Git verwaltenWalter Ebert
 
Debugging webOS applications
Debugging webOS applicationsDebugging webOS applications
Debugging webOS applicationsfpatton
 
Web development automatisation for fun and profit (Artem Daniliants)
Web development automatisation for fun and profit (Artem Daniliants)Web development automatisation for fun and profit (Artem Daniliants)
Web development automatisation for fun and profit (Artem Daniliants)LumoSpark
 
Don't Over-React - just use Vue!
Don't Over-React - just use Vue!Don't Over-React - just use Vue!
Don't Over-React - just use Vue!Raymond Camden
 
Internals - Exploring the webOS Browser and JavaScript
Internals - Exploring the webOS Browser and JavaScriptInternals - Exploring the webOS Browser and JavaScript
Internals - Exploring the webOS Browser and JavaScriptfpatton
 
Virtual Infrastructure
Virtual InfrastructureVirtual Infrastructure
Virtual InfrastructureBryan McLellan
 
Writing your Third Plugin
Writing your Third PluginWriting your Third Plugin
Writing your Third PluginJustin Ryan
 
Bfg Ploneconf Oct2008
Bfg Ploneconf Oct2008Bfg Ploneconf Oct2008
Bfg Ploneconf Oct2008Jeffrey Clark
 
Frédérick Capovilla
Frédérick CapovillaFrédérick Capovilla
Frédérick CapovillaWeb à Québec
 
WordPress Realtime - WordCamp São Paulo 2015
WordPress Realtime - WordCamp São Paulo 2015WordPress Realtime - WordCamp São Paulo 2015
WordPress Realtime - WordCamp São Paulo 2015Fernando Daciuk
 

Was ist angesagt? (20)

Taking the Friction Out of Ticket Investigation (Standardized Debugging Envir...
Taking the Friction Out of Ticket Investigation (Standardized Debugging Envir...Taking the Friction Out of Ticket Investigation (Standardized Debugging Envir...
Taking the Friction Out of Ticket Investigation (Standardized Debugging Envir...
 
Contributing to WordPress Core - Peter Wilson
Contributing to WordPress Core - Peter WilsonContributing to WordPress Core - Peter Wilson
Contributing to WordPress Core - Peter Wilson
 
Write php deploy everywhere tek11
Write php deploy everywhere   tek11Write php deploy everywhere   tek11
Write php deploy everywhere tek11
 
Automatisation in development and testing - within budget
Automatisation in development and testing - within budgetAutomatisation in development and testing - within budget
Automatisation in development and testing - within budget
 
Microservice Teststrategie mit Symfony2
Microservice Teststrategie mit Symfony2Microservice Teststrategie mit Symfony2
Microservice Teststrategie mit Symfony2
 
WordPress mit Composer und Git verwalten
WordPress mit Composer und Git verwaltenWordPress mit Composer und Git verwalten
WordPress mit Composer und Git verwalten
 
Debugging webOS applications
Debugging webOS applicationsDebugging webOS applications
Debugging webOS applications
 
Palestra VCR
Palestra VCRPalestra VCR
Palestra VCR
 
Vagrant for real
Vagrant for realVagrant for real
Vagrant for real
 
Web development automatisation for fun and profit (Artem Daniliants)
Web development automatisation for fun and profit (Artem Daniliants)Web development automatisation for fun and profit (Artem Daniliants)
Web development automatisation for fun and profit (Artem Daniliants)
 
Zenoss: Buildout
Zenoss: BuildoutZenoss: Buildout
Zenoss: Buildout
 
Don't Over-React - just use Vue!
Don't Over-React - just use Vue!Don't Over-React - just use Vue!
Don't Over-React - just use Vue!
 
Internals - Exploring the webOS Browser and JavaScript
Internals - Exploring the webOS Browser and JavaScriptInternals - Exploring the webOS Browser and JavaScript
Internals - Exploring the webOS Browser and JavaScript
 
Angular2 ecosystem
Angular2 ecosystemAngular2 ecosystem
Angular2 ecosystem
 
Virtual Infrastructure
Virtual InfrastructureVirtual Infrastructure
Virtual Infrastructure
 
Writing your Third Plugin
Writing your Third PluginWriting your Third Plugin
Writing your Third Plugin
 
Bfg Ploneconf Oct2008
Bfg Ploneconf Oct2008Bfg Ploneconf Oct2008
Bfg Ploneconf Oct2008
 
Frédérick Capovilla
Frédérick CapovillaFrédérick Capovilla
Frédérick Capovilla
 
WordPress Realtime - WordCamp São Paulo 2015
WordPress Realtime - WordCamp São Paulo 2015WordPress Realtime - WordCamp São Paulo 2015
WordPress Realtime - WordCamp São Paulo 2015
 
Intro to Silex
Intro to SilexIntro to Silex
Intro to Silex
 

Ähnlich wie How to start with eZ Publish 5

Learnings from Real eZ Publish 5 Projects
Learnings from Real eZ Publish 5 ProjectsLearnings from Real eZ Publish 5 Projects
Learnings from Real eZ Publish 5 ProjectsDonat Fritschy
 
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...Sébastien Morel
 
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
 
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
 

Ähnlich wie How to start with eZ Publish 5 (20)

Learnings from Real eZ Publish 5 Projects
Learnings from Real eZ Publish 5 ProjectsLearnings from Real eZ Publish 5 Projects
Learnings from Real eZ Publish 5 Projects
 
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
 

Kürzlich hochgeladen

Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 

Kürzlich hochgeladen (20)

Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 

How to start with eZ Publish 5

  • 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