Skip to content

Add new design

To create different designs for different version of the website, you configure different sites based on the SiteAccess content.

This example shows how to prepare a site for a "Summer Sale" marketing campaign and provide it with a distinct design.

Configure a new SiteAccess

First, in the SiteAccess configuration in config/packages/ezplatform.yaml, add the campaign SiteAccess to the list under ezplatform.siteaccess:

1
2
3
4
5
6
ezplatform:
    siteaccess:
        list: [site, campaign]
        groups:
            site_group: [site, campaign]
        default_siteaccess: site

Adding the campaign SiteAccess to site_group enables you to add common configuration for both SiteAccesses at the same time.

Tip

For details about configuring different site roots and matching SiteAccesses, see Set up campaign SiteAccess.

Create themes

Next, configure a new summersale design for this theme, also named summersale:

1
2
3
ezdesign:
    design_list:
        summersale: [summersale, standard]

Ensure that the campaign site uses this design (while the default site uses the default standard design)

1
2
3
4
5
6
7
8
ezplatform:
    system:
        campaign:
            languages: [eng-GB]
            design: summersale        
        site:
            languages: [eng-GB]
            design: standard

Add templates

Now, create templates for the two sites. Templates for the main site should be placed in templates/themes/standard, and templates for the campaign site in templates/themes/summersale.

First, modify the built-in general page layout template for the standard site in templates/themes/standard/pagelayout.html.twig by including a header and a footer section:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
<body>

{% include '@ezdesign/parts/header.html.twig' %}

{% block content %}
{% endblock %}

{% include '@ezdesign/parts/footer.html.twig' %}

{% block javascripts %}

@ezdesign in the template paths points to a template relevant for the current design. In case of site, the template used for the header is templates/themes/standard/parts/header.html.twig.

Create both the header and the footer template, for example:

1
<div class="page-header">{{ "My site"|trans }}</div>
1
<footer>Copyright Acme SA</footer>

Now, create templates for content, for example for an article, that extend the page layout:

1
2
3
4
{% extends '@ezdesign/pagelayout.html.twig' %}

{% block content %}
{% endblock %}

Configure the content view so that both sites, the main one and the campaign, use this template. To do it, use the site_group that both sites belong to:

1
2
3
4
5
6
7
8
9
ezplatform:
    system:
        site_group:
            content_view:
                full:
                    article:
                        template: '@ezdesign/full/article.html.twig'
                        match:
                            Identifier\ContentType: [ article ]

Now, create an Article Content item and preview it on the front page. You should see the article with a header and footer that you defined for the main site.

Override templates

Now, you need to override the header of the site to fit the campaign. Create a separate templates/themes/summersale/parts/header.html.twig file with different content, for example:

1
<div class="page-header">{{ "Welcome to the Summer Sale!"|trans }}</div>

Preview the Article through the campaign SiteAccess: <yourdomain>/campaign/<article-name>. You can see that the page uses the campaign header, while the rest of the layout, including the footer, is the same as in the main site. This is because you defined standard design as fallback for this SiteAccess:

1
2
3
ezdesign:
    design_list:
        summersale: [summersale, standard]

In this case, if the design engine cannot find a template for the current design, it uses the template from the next configured design. In the case above, the engine does not find the footer template for the campaign SiteAccess, so it uses the one from standard.

This way you do not need to provide all templates for a new design, but only those that you want to be different than the fallback one.