简体   繁体   中英

multisite eZ Platform installation

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!

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') %}

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 :)

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM