π§© JSON Menu Editor β PHP + Alpine.js (v2.0.0)
A robust, modular and extensible system for loading, editing, validating and saving multi-level menus stored in a menu.json file. Built with PHP, Alpine.js and TailwindCSS, this module now includes a visual menu editor, global field system, type-aware metadata propagation, and a fully safe JSON-saving workflow.
Ideal for dashboards, CMS-like control panels, embedded UIs or any environment that requires a structured, metadata-rich dynamic menu.
ποΈ Version History Version Date Description v1.0.0 Initial release Basic menu JSON loading and rendering. v2.0.0 Current Major update: Global Fields, rigid propagation, field types, updated editor UI, improved saving pipeline, and JSON normalization overhaul. β¨ Highlights of Version 2.0.0 𧬠1. Global Fields System (NEW)
Define fields that automatically apply to all menu items across all levels.
Each field includes:
Field name
Field type (string, number, boolean, json)
Default value
Ability to remove fields dynamically
These fields are then shown inside every menu item of the editor.
β Rigid propagation
Every item always contains all global fields.
β Guidance message added
Below the Global Fields section:
βAfter adding or removing global fields, save the menu so that these fields appear in all items.β
π 2. Updated Visual Menu Editor
Add/edit/remove menu items
Add siblings and nested items
Up to 3 levels
Automatic name rebuilding for nested structures
Global fields appear dynamically inside each item
Enhanced layout and accessibility
πΎ 3. Improved JSON Saving (save-menu.php)
Now includes:
Conversion of field values according to their type
Application of Global Field schema to all items
Removal of obsolete fields
Normalization of tags
Full recursive processing
Pretty-printed JSON
Success screen with Download menu.json button
π§ 4. Architecture Improvements
Safer parsing
Cleaner PHP structure (functions, includes)
Enhanced frontend integration with Alpine.js
Item editor dynamically reacts to global field changes
π Project Structure menu-json-editor/ β βββ assets/ β βββ data/ β β βββ menu.json β βββ icons/ β βββ css/ β βββ main.css β βββ assets/js/ β βββ menu-editor.js β NEW v2.0.0 β βββ dashboard.js β βββ menu.js β βββ menu-manager.js β βββ src/ β βββ includes/ β β βββ header.php β β βββ footer.php β βββ functions/ β βββ menu.php β βββ menu-editor.php β UPDATED v2.0.0 β βββ save-menu.php β UPDATED v2.0.0 β βββ menu-manager.php βββ README.md
π How to Run
Start a PHP server:
php -S localhost:8000
Open:
http://localhost:8000/menu-manager.php
π Workflow (v2.0.0)
menu.php loads JSON
menu-editor.php displays items + global fields
User edits both
Saving applies rigid schema enforcement
JSON is normalized and written to file
User may download updated menu.json
π§ͺ Validation & Safety
β HTML sanitized β JSON validated β Field type casting β Rigid schema propagation β Error details shown clearly
π Requirements
PHP 8+
No database required
Works on any hosting environment
π©βπ» Author
Livia PΓ©rez Bettero
π€ Technical Collaboration
ChatGPT (OpenAI)