From f2021361ec5f8de29a30698bab41902d66fc7638 Mon Sep 17 00:00:00 2001 From: Dmielgo Date: Tue, 24 Mar 2026 16:17:00 +0000 Subject: [PATCH] Add production rules discovered during real projects - Correct hooks-and-api.md: file hooks vs module hooks param injection, FK naming not always _num, CmsApi.hook Promise pattern - Add 9 new rules to hooks-and-api.md: reserved `tipo` var, ghost modules, cms_uploads schema, name vs title by menuType, menuOrder, localCache gotcha, slug generation, uploads from hooks, CocoEmail - Add 5 rules to modular-system.md: minified/ dir, Docker workflow, debug tools (?compiletwig/?pruebas), general sections deploy, controlador - Add 2 rules to css-js-conventions.md: Vue inline conflict, Vue mount delay - Add testing section to quick-reference.md - Create docs/deploy-and-sync.md for production deploy and sync rules - Promote 3 critical rules to CLAUDE.md (rules 11-13) Co-Authored-By: Claude Opus 4.6 (1M context) --- CLAUDE.md | 4 + docs/css-js-conventions.md | 16 ++++ docs/deploy-and-sync.md | 56 +++++++++++++ docs/hooks-and-api.md | 158 +++++++++++++++++++++++++++++++++++-- docs/modular-system.md | 50 +++++++++++- docs/quick-reference.md | 8 ++ 6 files changed, 283 insertions(+), 9 deletions(-) create mode 100644 docs/deploy-and-sync.md diff --git a/CLAUDE.md b/CLAUDE.md index f0d0832..b8f2358 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -102,6 +102,9 @@ Do NOT modify web-base files — they are shared across all projects. 8. Tailwind CSS as primary styling, custom CSS scoped with BEM when needed 9. Twig concatenation uses `~` operator: `'value=' ~ variable` 10. `enlace` (link) fields already include slashes +11. **File hooks (`hooks/*.php`) do NOT inject variables.** Always read params manually: `$params = json_decode(file_get_contents('php://input'), true) ?: [];` — Only module hooks (`modulos/*/hook.php`) receive variables directly. +12. **`tipo` is a reserved variable.** The `.htaccess` injects `tipo=barra` on every request. Never use `tipo` as a hook parameter name — it gets overwritten, causing 404s. Use `account_type`, `user_tipo`, etc. +13. **Never pass `html` via `save_module` to modules with configured builder vars** (banners, carousels, modules with images/colors set from admin). It corrupts the visual configuration. Only pass `js` and/or `css`. See [docs/deploy-and-sync.md](docs/deploy-and-sync.md). ## Documentation @@ -114,3 +117,4 @@ Do NOT modify web-base files — they are shared across all projects. - [docs/production-patterns.md](docs/production-patterns.md) — Real production patterns (header, zigzag, FAQ, forms) - [docs/vue-builder-rules.md](docs/vue-builder-rules.md) — CMS-VUE rules (tabs, colorpicker, components) - [docs/vue-builder-examples.md](docs/vue-builder-examples.md) — Vue builder examples (Banner Slideshow, etc.) +- [docs/deploy-and-sync.md](docs/deploy-and-sync.md) — Deploy to production (save_module, sync, minified regeneration) diff --git a/docs/css-js-conventions.md b/docs/css-js-conventions.md index 8460082..ca477f4 100644 --- a/docs/css-js-conventions.md +++ b/docs/css-js-conventions.md @@ -83,9 +83,17 @@ if (section) { ### CmsApi (Client-Side) ```js +// Callback CmsApi.hook('/hooks/module_id/', { action: 'getData', id: 123 }, function(response) { console.log(response); }); + +// Promise +CmsApi.hook('/hooks/module_id/', { action: 'getData', id: 123 }).then(function(res) { + console.log(res); +}).catch(function(err) { + console.error(err); +}); ``` ### Cuándo usar Vue 3 @@ -123,6 +131,8 @@ createApp({ Siempre usar `'${'` y `'}'` como delimitadores Vue para evitar conflicto con Twig. +**IMPORTANTE: JS Vue SIEMPRE en `script.js`, nunca inline.** Twig también interpreta `${ }`. Si el JS con Vue está inline en `