Multitenancy (multitenancy_phoenix v0.2.0)

Copy Markdown View Source

Host-resolved multi-site theming for Phoenix.

A request host is resolved to a Multitenancy.Site, each site points to a theme living under themes/<name>/, and every theme is a self-contained slice of the application with its own router, controllers, templates, layouts, assets and gettext backend. Templates missing from a theme fall back to the base application (see Multitenancy.HTML).

Summary

Functions

Hosts served by the platform router instead of a theme.

Whether path_info falls under one of the prefixes ("/admin" matches /admin/sites).

Path prefixes served by the platform router on every host, such as an admin area or health checks shared by all sites.

The configured Multitenancy.SiteResolver implementation.

Fetches the theme definition for name.

The module conventionally defining the theme name, e.g. Themes.MyStore.

Names of the theme directories found under themes_path/0.

Directory holding the themes, relative to the project root.

Functions

platform_hosts()

Hosts served by the platform router instead of a theme.

platform_path?(path_info, prefixes)

@spec platform_path?([String.t()], [String.t()]) :: boolean()

Whether path_info falls under one of the prefixes ("/admin" matches /admin/sites).

platform_paths()

Path prefixes served by the platform router on every host, such as an admin area or health checks shared by all sites.

resolver()

The configured Multitenancy.SiteResolver implementation.

theme(name)

@spec theme(String.t() | atom()) :: {:ok, Multitenancy.Theme.t()} | :error

Fetches the theme definition for name.

theme!(name)

@spec theme!(String.t() | atom()) :: Multitenancy.Theme.t()

Same as theme/1 but raises Multitenancy.ThemeNotFoundError.

theme_module(name)

The module conventionally defining the theme name, e.g. Themes.MyStore.

theme_names(root \\ themes_path())

Names of the theme directories found under themes_path/0.

themes_path()

Directory holding the themes, relative to the project root.