# va-themes/cleverphant

Cleverphant — content website theme for educational institutions.
Redesign base for cleverphant.lt (WordPress Bricks original).

## Status

Inactive by default. Activate via admin Themes UI or `php artisan db:seed --class=...ThemeSeeder`.

## Structure

- `src/Providers/ThemeServiceProvider.php` — extends BaseThemeServiceProvider
- `Resources/views/` — Blade overrides for Pages, News, NewsCategories modules
- `Resources/views/template-editors/` — theme-OWNED admin widgets contributed to the
  Pages "Template" tab through `templateEditors()` (not overrides — see below)
- `Resources/assets/` — Vite source (tokens, per-section CSS, per-component JS)
- `Database/Seeders/CleverphantThemeSeeder.php` — DB row seeder
- `theme.json` — admin themes:sync metadata
- `public/build/` — Vite build output (published to host via vendor:publish)

**No `Routes/`, no `src/Http/` and no `Database/Migrations/`** — deliberately, since
PackageStructure/task-21 and task-22. A theme may not declare routes, carry controllers or
own migrations (`.claude/module-structure.md` §5). The one migration this theme used to
ship — `2026_07_02_000001_repair_cleverphant_page_templates`, which rewrites stale
`pages.template` values — now lives in `va-modules/pages`, the package that creates both the
table and that column. Its file NAME is unchanged, so the `migrations` ledger still sees it
as ran; a `migrate:status` after the update must show **no new Pending**. `Database/Seeders/`
stays here — seeders are content, and this theme's content is its own.

## Page templates — what this theme contributes, and what it does not

The bespoke page designs are contributed through the `ThemeTemplateRegistry`, never
through routes:

| Hook | What it declares | Consumed by |
|---|---|---|
| `webPageTemplates()` | selectable template codes + labels | Pages "Template" dropdown |
| `templateSlots()` | per-template editable text slots | Pages "Šablonas" tab form |
| `templateEditors()` | a bespoke editor VIEW for a template | Pages "Šablonas" tab, via `@includeIf` |

The tab itself — route (`admin.pages.template[.update]`, `admin.pages.template-images`),
controller, form and both base views — lives in **`va-modules/pages`**, because the column
it writes (`pages.template_data`) is declared by that package's migration and cast on its
`Page` model. Until PackageStructure/task-21 all of it lived here, grafted onto the Pages
module via `EnvRouteRegistrar`.

⚠️ A `templateEditors()` view must resolve on **admin** requests, so it is addressed as
`cleverphant::…` — `theme::` in the admin environment points at the ADMIN theme
(viartas-default), not at this one. That is why `boot()` registers the `cleverphant::`
namespace unconditionally rather than inside the active-theme gate.

## Page content management

The 9 cleverphant pages are seeded via:

```bash
php artisan cleverphant:seed-pages              # firstOrCreate (default, preserves edits)
php artisan cleverphant:seed-pages --dry-run    # preview changes, touch nothing
php artisan cleverphant:seed-pages --force      # overwrite existing rows (asks to confirm)
```

If your host already had Protera-era pages with slugs `kontaktai`, `pristatymas`,
or `privatumo-politika`, the default seeder skips them (preserves admin edits).
Run `--force` once after install to replace them with cleverphant content. After
that the CKEditor admin UI is the single source of truth — `--force` is no longer
needed. Force is intentionally NOT wired into `cleverphant:activate` (activate is
non-destructive; force overwrites page bodies).

## Clean-slate install (foreign-content wipe)

`cleverphant:install` is **destructive by default** (task-34): it wipes every
non-Cleverphant web content row BEFORE seeding, so `/duk` + `/tinklarastis` show
only Cleverphant content. `--additive` opts out (keeps coexisting rows).

```bash
php artisan cleverphant:install                 # destructive: wipe foreign, seed cleverphant, activate
php artisan cleverphant:install --additive      # keep existing non-Cleverphant content
php artisan cleverphant:install --dry-run        # preview the wipe + seed plan
```

The wipe lives in `CleverphantContentWiper` and uses a **page-slug allowlist**
(keeps Cleverphant's own 10 pages, wipes the rest; News/FAQ wiped in full) — this
predates and differs from the theme-agnostic
`ViartasCore\Core\Support\ForeignCmsContentWiper` used by `florial:seed-content
--fresh` and `seglo:install --wipe-foreign`. Cleverphant keeps its allowlist
variant deliberately: its Pages seeder is `firstOrCreate`, so admin edits to
Cleverphant pages survive a re-install (a purge-then-reseed would drop them).

See `.claude/tasks/Cleverphant/README.md` for full implementation chain.
