Multisite Any Field Icon

Multisite Any Field

Multisite Any Field Main Screenshot

Fieldtype for entering localized values in places Statamic doesn't usually localize β€” asset blueprints, form configs, globals without localization, and other "site-less" contexts.

It wraps a single field of any type, stores one value per site, and augments to the current site's value on the frontend.

Installation

composer require daun/statamic-multisite-field

Usage

Add a multisite field to a blueprint and configure the field it wraps. Define display and instructions on the root multisite field, not the wrapped field.

caption:
type: multisite
display: 'Caption'
instructions: 'Shown below the image'
field:
type: text

Frontend Display

Values are augmented to the current site's value on the frontend. Use like any other field.

{{ caption }}

Storage

Values are stored keyed by site handle.

caption:
en: 'Welcome home'
fr: 'Bienvenue chez vous'

Existing fields

Upgrading an existing field (e.g. text or url) to multisite just works: previously stored values are treated as the default site's value and upgraded to the per-site format on the next save.

Field Configuration

Option Default Description
field β€” The wrapped field's configuration (required).
layout tabs How to display the sites: one at a time behind a switcher (tabs, bottom, start, end) or all at once (stack).
inherit true Fall back to the default site's value when a site has no own value.
fallback β€” Handle of a sibling field in the same publish context to fall back to when the default site has no value.

Site Switcher Layout

In the control panel, the field shows the input for a single site at a time. Switch sites with the tabs above the field. All multisite fields on a page switch together, so you always see one consistent site across the form.

The layout field config controls how to switch sites.

Tabs

The default value of tabs shows a tab bar above the field.

Button Groups

The values bottom, start or end show a button group next to the field.

Stacked

The value stack shows all sites in a single column, without a switcher.

Inheritance

A multisite field can inherit from a sibling in the same blueprint, in addition to inheriting between its own sites. This is useful for adding optional per-site translations of a field that already has a default value.

display:
type: text
 
display_i18n:
type: multisite
inherit: true
fallback: display
field:
type: text

Global Site Switcher

With many multisite fields on one form, the per-field switchers add up. Add a multisite_switcher field to the blueprint to show a single global switcher that controls all multisite fields. Any multisite fields on the same form will then hide their own switchers.

Choose between three layouts: tabs, buttons or dropdown.

site_switcher:
type: multisite_switcher
layout: tabs

The switcher is a display-only field β€” it stores no data.

Limitations

  • Listings and previews use the default site's value.
  • Field conditions targeting the wrapped field are not supported.

License

MIT