Skip to content

Sites and Languages

Phillip Dornauer edited this page Apr 1, 2026 · 2 revisions

Sites & Languages

Multi-Site

Marble supports running multiple sites from one installation. Each site has its own domain, root item, settings item, and default language.

Managing Sites

Go to System → Sites in the admin.

Site Properties

Property Description
Name Display name
Domain Hostname (e.g. example.com)
Root Item Top-level item of this site's content tree
Settings Item Item returned by Marble::settings() for this site
Default Language Fallback language
Default Used as fallback when no domain matches
Active Disable without deleting

Site Resolution

Marble matches the incoming request hostname to a site's domain. If no match, the default site is used.

$site = Marble::currentSite();

Multi-Language

Languages are managed under System → Languages. Each has a code (en, de, fr) and a name.

Translatable Fields

Enable Translatable per blueprint field to store separate values per language. The editor shows a language switcher at the top. Non-translatable fields store a single value.

URL Locale Prefix

Controls whether language codes appear in frontend URLs.

uri_locale_prefix = false (default)

All language slugs are served directly, without any prefix. /about-us and /ueber-uns both work and resolve to the same item in their respective languages. Marble detects the language from the slug.

/about-us      → item in English
/ueber-uns     → same item in German

uri_locale_prefix = true

Every URL is prefixed with the language code. All languages, including the primary, get a prefix.

/en/about-us   → item in English
/de/ueber-uns  → same item in German

Translation Fallback

When a field has no translation for the current language (empty or not yet translated), Marble automatically falls back to the primary language value. This means your site will always show content — even if only partially translated — rather than empty fields.

The slug field is never subject to fallback: each language uses its own slug to determine which language to render.

Setting the Language in Code

Marble::setLocale('de');
Marble::setLanguageById(2);
Marble::currentLanguageId();
Marble::primaryLanguageId();

Language-Specific Values in Templates

{{ $item->value('title') }}           {{-- Current language --}}
{{ $item->value('title', 'de') }}     {{-- German --}}
{{ $item->value('title', 2) }}        {{-- Language ID 2 --}}

Generating Language-Specific URLs

{{ Marble::url($item) }}          {{-- Current language --}}
{{ Marble::url($item, 'de') }}    {{-- German URL --}}

Copying Language Content

In the item editor sidebar, use Copy Language to copy all field values from one language to another. Useful when starting a translation.

Clone this wiki locally