Skip to content

Multisite Pro Feature

Since October CMS 3.1 Multisite content is supported natively.

Boxes provides first-party support for multisite content.

Creating content for multiple sites

When switching Sites in the October CMS backend, the Boxes Editor will ask you to create a copy of the currently edited page for the new Site.

Between Sites, you will always work on copies of a page. No data is shared between Sites.

Once a Boxes Page was created on a new Site, you can use the Page on main site dropdown to select a page on the main site that this new page belongs to.

When a user switches Sites in the frontend, Boxes will automatically work out the correct page for the selected Site and redirect the user.

Displaying a site picker

You can use the native sitePicker component from October CMS to display a site picker. Boxes will handle the URL creation for you.

twig
[sitePicker]
==
<ul>
    {% for site in sitePicker.sites %}
        <li>
            <a href="{{ site.url }}">
                {{ site.locale }}
            </a>
        </li>
    {% endfor %}
</ul>

Relations

There are a few relations available when using the multisite feature:

  • site returns the related site
  • root_page returns the related page from the main site
  • current_site_page always returns the related page for the currently active site
  • multisite_pages returns all related pages from all sites

Examples

twig
<p>This page is available in the following languages:</p>

<ul>
    {% for page in boxesPage.multisite_pages %}
        <li>
            <a href="{{ page.site.base_url }}{{ page.url }}">
                {{ page.site.locale }}
            </a>
        </li>
    {% endfor %}
</ul>

Mirror all Boxes pages to a new Site

When adding a new Site to your October CMS installation, you can use the boxes:mirror-site console command to create a 1:1 copy of all Pages on the newly created site.

Simply specify the ID of the source Site and the ID of the target Site when calling the command:

WARNING

Since this is a possibly destructive operation, make sure to back up your database before running this command. All Boxes Pages on the target site will be deleted before the new pages are created.

bash
# Mirror Site 1 to Site 2
php artisan boxes:mirror-site --from=1 --to=2