multisite eZ Platform installation

203 Views Asked by At

I'm building a multisite eZ Platforme installation and I need to specify a main layout for my templates. Right now I have a template article.html.twig :

{% extends "main_layout.html.twig" %}

{% block content %}
    <h1>{{ ez_render_field(content, 'body') }}</h1>
{% endblock %}

what I want to do is something like this :

 {% if(siteaccess = "site1"){
        extends "site1_main_layout.html.twig"
  }
 else if(siteaccess = "site2"){
        extends "site1_main_layout.html.twig" 
  }
 %}

Please help me!

3

There are 3 best solutions below

1
On BEST ANSWER

You can just configure the layout in the config:

ezpublish:
    system:
        site1:
            pagelayout: "tpl1.html.twig"
        site2:
            pagelayout: "tpl2.html.twig"

After that, you can just use the following in your full view:

{% extends pagelayout %}

{% block content %}
    ...
{% endblock %}

pagelayout is a variable prepopulated by eZ Platform from the above config based on current siteaccess. It requires eZ Platform 1.2 at the least, I believe.

It should also be noted that pagelayout variable is available only in full view templates. Other templates wishing to use the configured pagelayout must use the following:

{% extends ezpublish.configResolver.parameter('pagelayout') %}
0
On

Have a look here https://doc.ezplatform.com/en/latest/guide/design_engine/

you can use the Design engine where you can set up different themes with fallback. Define one base theme an add per siteaccess one extra theme where you can override any template.

0
On

Correct me if I misunderstood your goal, but do you recon it could be sorted by checking the domains? (I am assuming they would be different so could serve as a separator):

{% if app.request.baseUrl == 'site1' %}
    ...
{% else %}
   ...
{% endif %}

If I am not wrong, I also belive you can create a default Twig Controller Loader to decide this beforehand instead of leaving the logic to your views :)