Run the following command to install Netgen Layouts & Sylius eCommerce integration:
composer require netgen/layouts-standard netgen/layouts-sylius
After completing standard Layouts install instructions, you also need to
activate NetgenLayoutsSyliusBundle
and NetgenContentBrowserSyliusBundle
.
Make sure they are activated after all other Netgen Layouts and Content Browser bundles:
...
$bundles[] = new Netgen\Bundle\LayoutsSyliusBundle\NetgenLayoutsSyliusBundle();
$bundles[] = new Netgen\Bundle\ContentBrowserSyliusBundle\NetgenContentBrowserSyliusBundle();
return $bundles;
Due to how Netgen Layouts works, your main layout template needs to wrap the
content
block inside a new layout
block:
{% block layout %}
{% block content %}
{% endblock %}
{% endblock %}
All full view templates (those that are rendered directly by controllers), need
to extend nglayouts.layoutTemplate
instead of your original layout:
{% extends nglayouts.layoutTemplate %}
{% block content %}
...
{% endblock %}
This allows Netgen Layouts to inject a layout resolved for the request into your page. Since you configured all your full views to now use Netgen Layouts, they will not fallback to your main layout template. Because of that, you need to configure Netgen Layouts with your main layout template, so the fallback keeps working as it should.
Add the following to your app/config/config.yml
file to configure the layout
and specify the default design for block and layout templates:
netgen_layouts:
pagelayout: '@MyShop/layout.html.twig'
design: sylius
Netgen Layouts requires that ESI and fragments support is activated in Symfony.
Add the following to your app/config/config.yml
file:
framework:
esi: ~
fragments: ~
To properly integrate Netgen Layouts and Sylius admin interfaces, you need to
update (or add, if missing) admin regex parameter in your
app/config/security.yml
file to allow access to Netgen Layouts admin routes:
parameters:
sylius.security.admin_regex: "^(/admin|/nglayouts/app|/nglayouts/api|/nglayouts/admin|/cb)"