HifiPlanet-Website/hifi/api/database/migration_home_sections.sql
Maaxxs ba4fa986d3 Make the homepage's main marketing text blocks editable
Extends the CMS work (Phase 5) to the content the user pointed out was
still missing, using the YouTube section as the concrete example: text,
alignment, and the button link weren't editable anywhere. Rather than
patch that one section, this builds the reusable pattern the user asked
for and applies it to every comparable text block on the homepage:
hero (text only, its two nav buttons stay fixed), the YouTube section,
the craft and consultation blocks, the gallery intro, and the "more
than car-hifi" block.

New home_sections table (bilingual DE/EN, like faqs, since the site has
a language switcher) + HomeSectionController, following the same
DB-row-with-built-in-defaults pattern as legal_pages: a section not yet
customized returns the exact text that used to be hard-coded in the
i18n dictionary, so nothing on a live site goes blank. New "Startseite"
admin page (content.manage, alongside FAQ) with per-section DE/EN tabs,
reusing the Phase 4 RichTextEditor for the body text and a plain
alignment dropdown. Wired into export/import (Settings -> Export &
Import) alongside the other content sections.

Alignment is applied via fixed left/center/right class lookup tables in
Home.jsx rather than a template-string class name, since Tailwind's
build-time scanner needs literal class names present in the source to
avoid purging them from the production CSS.

Known trade-off: two sections (hero, "more than car-hifi") previously
had hand-tuned responsive alignment that differed by breakpoint
(e.g. centered on mobile, left-aligned on desktop for "more"). Making
alignment a single admin-editable value necessarily replaces that with
one fixed choice at every breakpoint - simpler to reason about and
control, at the cost of that responsive nuance.

Verified end-to-end against the local database directly via PHP CLI
(bypassing a local Apache path-routing quirk unrelated to this change):
confirmed defaults come back correctly before any row exists, and that
saving and reading back a row round-trips correctly - then removed the
test row before finishing.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-09 02:51:00 +02:00

23 lines
1,001 B
SQL

USE hifi_shop;
-- Die wichtigsten Text-Abschnitte der Startseite (YouTube-Sektion, Handwerk/Beratung,
-- Einblicke, "Mehr als Car-Hifi") als editierbare Bloecke statt hart im JSX codiert.
-- Zweisprachig (DE/EN, wie bei faqs), da die Seite einen Sprachumschalter hat.
-- Fehlt eine Zeile fuer einen Slug, liefert HomeSectionController einen eingebauten
-- Standardtext (siehe DEFAULTS dort - identisch zum bisherigen i18n-Text).
CREATE TABLE IF NOT EXISTS home_sections (
id INT AUTO_INCREMENT PRIMARY KEY,
slug VARCHAR(50) NOT NULL UNIQUE,
eyebrow_de VARCHAR(150) NULL,
eyebrow_en VARCHAR(150) NULL,
title_de VARCHAR(255) NULL,
title_en VARCHAR(255) NULL,
body_html_de TEXT NULL,
body_html_en TEXT NULL,
text_align ENUM('left','center','right') NOT NULL DEFAULT 'center',
button_label_de VARCHAR(100) NULL,
button_label_en VARCHAR(100) NULL,
button_url VARCHAR(500) NULL,
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB;