# eastslopestudio/craft-sites-field architecture

> Architecture diagram of the GitHub repository eastslopestudio/craft-sites-field, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/eastslopestudio/craft-sites-field
- Repository: https://github.com/eastslopestudio/craft-sites-field

## Overview

Sites Field is a small Craft CMS plugin that registers a custom field for selecting one or more sites. Editors configure a site whitelist, choose site IDs on content entries, and templates can read the resulting field value. The runtime is centered on one field class, which supplies settings and input templates, validates selections, and retrieves available sites through Craft. Template relationships are supported by the field’s render calls; template internals were not sampled.

Main entry points: [`src/fields/SitesField.php`](https://github.com/eastslopestudio/craft-sites-field/blob/master/src/fields/SitesField.php) (Sites field), [`src/Sites.php`](https://github.com/eastslopestudio/craft-sites-field/blob/master/src/Sites.php) (Plugin entry), [`src/templates/_settings.html`](https://github.com/eastslopestudio/craft-sites-field/blob/master/src/templates/_settings.html) (Settings template), [`src/templates/_input.html`](https://github.com/eastslopestudio/craft-sites-field/blob/master/src/templates/_input.html) (Input template)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_plugin["Plugin registration"]
  node_plugin_entry["Plugin entry<br/>[Sites.php]"]
end

subgraph group_field["Site field"]
  node_sites_field["Sites field<br/>[SitesField.php]"]
  node_settings_template["Settings template<br/>[_settings.html]"]
  node_input_template["Input template<br/>[_input.html]"]
end

node_craft(("Craft CMS"))
node_craft_sites["Craft sites service"]
node_content_entry["Content entry"]
node_site_value["Selected site ID"]

node_craft -->|"loads plugin"| node_plugin_entry
node_plugin_entry -->|"registers type"| node_sites_field
node_sites_field -->|"gets sites"| node_craft_sites
node_sites_field -->|"renders settings"| node_settings_template
node_sites_field -->|"renders input"| node_input_template
node_content_entry -.->|"uses field"| node_sites_field
node_sites_field -->|"normalizes value"| node_site_value
node_site_value -.->|"available to templates"| node_content_entry

click node_plugin_entry "https://github.com/eastslopestudio/craft-sites-field/blob/master/src/Sites.php"
click node_sites_field "https://github.com/eastslopestudio/craft-sites-field/blob/master/src/fields/SitesField.php"
click node_settings_template "https://github.com/eastslopestudio/craft-sites-field/blob/master/src/templates/_settings.html"
click node_input_template "https://github.com/eastslopestudio/craft-sites-field/blob/master/src/templates/_input.html"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_plugin_entry toneBlue
class node_sites_field,node_settings_template,node_input_template toneAmber
class node_craft,node_craft_sites,node_content_entry,node_site_value toneIndigo
```

## Components

### Plugin registration

- [Plugin entry](https://github.com/eastslopestudio/craft-sites-field/blob/master/src/Sites.php): `src/Sites.php`

### Site field

- [Sites field](https://github.com/eastslopestudio/craft-sites-field/blob/master/src/fields/SitesField.php): `src/fields/SitesField.php`
- [Settings template](https://github.com/eastslopestudio/craft-sites-field/blob/master/src/templates/_settings.html): `src/templates/_settings.html`
- [Input template](https://github.com/eastslopestudio/craft-sites-field/blob/master/src/templates/_input.html): `src/templates/_input.html`

### Other components

- **Craft CMS**
- **Craft sites service**
- **Content entry**
- **Selected site ID**

## Connections

- Craft CMS → Plugin entry: loads plugin (evidence: `src/Sites.php`)
- Plugin entry → Sites field: registers type (evidence: `src/Sites.php`)
- Sites field → Craft sites service: gets sites (evidence: `src/fields/SitesField.php`)
- Sites field → Settings template: renders settings (evidence: `src/fields/SitesField.php`)
- Sites field → Input template: renders input (evidence: `src/fields/SitesField.php`)
- Content entry → Sites field: uses field
- Sites field → Selected site ID: normalizes value (evidence: `src/fields/SitesField.php`)
- Selected site ID → Content entry: available to templates
