de codex
This commit is contained in:
@@ -37,14 +37,24 @@ Each module lives in `template/estandar/modulos/<moduleId>/` with:
|
||||
|
||||
## Creating a Module — Full Workflow
|
||||
|
||||
If the module needs server-side logic, dynamic data processing, form handling, or reusable backend behavior, read `docs/hooks-and-api.md` before creating `hook.php` or any global hook.
|
||||
If the module needs JavaScript, you MUST read `docs/css-js-conventions.md` before writing `index-base.tpl` or `script.js`.
|
||||
If the module needs server-side logic, dynamic data processing, form handling, or reusable backend behavior, you MUST read `docs/hooks-and-api.md` before creating `hook.php` or any global hook.
|
||||
If the module will call hooks from Twig, also review `docs/twig-filters.md` for the `hook` filter syntax.
|
||||
|
||||
Hard rules for module files:
|
||||
- `index-base.tpl` is for HTML/Twig only
|
||||
- `script.js` is for module JavaScript
|
||||
- `style.css` is for module CSS
|
||||
- `hook.php` is for server-side logic
|
||||
- Do NOT embed `<script>` tags in `index-base.tpl`
|
||||
- Do NOT put PHP logic in `index-base.tpl`
|
||||
|
||||
1. **Read style reference** (steps above)
|
||||
2. **`acai-write`** — Create the module files directly (`index-base.tpl`, `style.css`, `script.js`, optional `hook.php`) using project-relative paths and complete file contents.
|
||||
- If the server-side logic belongs only to that module, create `template/estandar/modulos/<module-id>/hook.php`
|
||||
- If the logic should be reused across modules/pages, create a global hook in `hooks/hooks.<hook-id>.php`
|
||||
- Inside the module, reference its own hook with `/hooks/<module-id>/`
|
||||
- Example: module folder `template/estandar/modulos/buscadorapartados_hjd8s/` -> hook endpoint `/hooks/buscadorapartados_hjd8s/`
|
||||
3. **Automatic compile** — Writing `index-base.tpl` automatically creates the generated template placeholders and triggers compilation. `compile_module` is only a manual recovery tool if you need to force a recompile without changing the file.
|
||||
4. **`add_module_to_record`** — Adds the module to a page. Response includes `sectionId` — use it directly in the next step.
|
||||
5. **`set_module_config_vars`** — Fill variables with content. Response includes `uploadFields` with `{ fieldName, recordNum }` for each upload variable.
|
||||
|
||||
Reference in New Issue
Block a user