Add complete Acai development documentation
- CLAUDE.md: expanded with critical rules, hook syntax, DB conventions, web-base endpoint - docs/modular-system.md: modules, general sections, global vars, multiv2 - docs/builder-fields.md: all field types, c-if/c-for/c-class, c-form, built-in components - docs/twig-filters.md: get, hook, module, queryDB, imagec, translate, raw, etc. - docs/hooks-and-api.md: PHP hooks, CmsApi CRUD, table schemas, field formats - docs/css-js-conventions.md: Tailwind, BEM, CSS vars, Vue 3 integration, CmsApi JS Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
51
CLAUDE.md
51
CLAUDE.md
@@ -6,7 +6,7 @@ This is an Acai CMS website project. Follow these instructions when working with
|
||||
|
||||
- The site runs in Docker, typically at **http://localhost:8080**
|
||||
- You can make HTTP requests to test pages, APIs, or form submissions
|
||||
- If you need to inspect the live site, use browser tools or HTTP requests to localhost:8080
|
||||
- If you need to inspect the live site, use browser tools (Playwright MCP) or HTTP requests to localhost:8080
|
||||
|
||||
## Project Structure
|
||||
|
||||
@@ -15,10 +15,12 @@ This is an Acai CMS website project. Follow these instructions when working with
|
||||
├── template/estandar/
|
||||
│ ├── modulos/ # Builder modules (visual components)
|
||||
│ │ └── <module-id>/
|
||||
│ │ ├── index-base.tpl # Twig template (source)
|
||||
│ │ ├── index.tpl # Compiled template (auto-generated, do NOT edit)
|
||||
│ │ ├── index-base.tpl # Twig template (source — EDIT THIS)
|
||||
│ │ ├── style.css # Module styles
|
||||
│ │ └── script.js # Module JavaScript
|
||||
│ │ ├── index.tpl # Compiled (auto-generated, do NOT edit)
|
||||
│ │ ├── index-twig.tpl # Compiled (auto-generated, do NOT edit)
|
||||
│ │ └── builder.json # Compiled builder vars (auto-generated, do NOT edit)
|
||||
│ ├── css/ # Global CSS
|
||||
│ └── js/ # Global JavaScript
|
||||
├── hooks/ # PHP hooks (server-side logic)
|
||||
@@ -38,17 +40,28 @@ This is an Acai CMS website project. Follow these instructions when working with
|
||||
## Key Concepts
|
||||
|
||||
### Modules (`template/estandar/modulos/`)
|
||||
Visual components that the site builder uses. Each module is a self-contained unit with its own template (Twig), CSS, and JS. Modules are placed on pages via the drag-and-drop builder.
|
||||
Visual components that the site builder uses. Each module is a self-contained unit with its own template (Twig + Acai attributes), CSS, and JS. Modules are placed on pages via the drag-and-drop builder. The editable file is always `index-base.tpl`.
|
||||
|
||||
- Include other modules: `<module_id :param1="value1"></module_id>`
|
||||
- Each module instance gets a unique `section_id` variable for anchors/scoping
|
||||
- Use `interno` variable to detect CMS editor mode vs public view
|
||||
|
||||
See [docs/modular-system.md](docs/modular-system.md) for detailed rules.
|
||||
|
||||
### General Sections
|
||||
Reusable layout blocks (header, footer, sidebars) that appear across multiple pages. They use the same Twig engine as modules but serve a structural purpose.
|
||||
Database-backed templates (headers, footers, record views) that use the `thisrecord` variable to access record fields. They use the same Twig + Acai attribute engine as modules.
|
||||
|
||||
- Upload fields return arrays: `thisrecord.image[0].urlPath`
|
||||
- Foreign keys use `_num` suffix: `category_num`
|
||||
|
||||
See [docs/modular-system.md](docs/modular-system.md) for details.
|
||||
|
||||
### Hooks (`hooks/`)
|
||||
PHP files that execute server-side logic at specific points: before/after page load, on form submission, on API calls, scheduled tasks, etc. Hooks extend the CMS behavior without modifying the core.
|
||||
PHP files that execute server-side logic. Triggered by:
|
||||
- Twig filter: `'hooks/module_id/' | hook({param: value})`
|
||||
- HTML tag: `<hook result="var" endpoint="/hooks/module_id/" :param="value"></hook>`
|
||||
- JavaScript: `CmsApi.hook('/hooks/module_id/', {param: value}, callback)`
|
||||
- Form action: via `c-form` attribute
|
||||
|
||||
See [docs/hooks-and-api.md](docs/hooks-and-api.md) for usage.
|
||||
|
||||
@@ -57,25 +70,41 @@ See [docs/hooks-and-api.md](docs/hooks-and-api.md) for usage.
|
||||
When the site is running in Docker, you can connect to the database:
|
||||
|
||||
- **Host:** `127.0.0.1`
|
||||
- **Port:** Check `.docker/.env` or `docker-compose.yml` for the mapped port (usually 3307+)
|
||||
- **Port:** Check `.docker/docker-compose.yml` for the mapped port (usually 3307+)
|
||||
- **Credentials:** Read from `.docker/.env`:
|
||||
- `DB_USERNAME`
|
||||
- `DB_PASSWORD`
|
||||
- `DB_DATABASE`
|
||||
|
||||
You can also exec into the container:
|
||||
```bash
|
||||
docker exec -it dw-<project-name>-db mysql -u root -p<password> <database>
|
||||
```
|
||||
|
||||
**Important:** Table names in CmsApi/Twig do NOT use the `cms_` prefix. The primary key is always `num`, never `id`.
|
||||
|
||||
## Acai Core (web-base)
|
||||
|
||||
The project workspace contains only the **customization layer** (modules, hooks, schemas, uploads). The CMS core (routing, rendering engine, admin panel, APIs) lives in a separate directory called **web-base** that is mounted as a Docker volume.
|
||||
|
||||
If you need to understand core behavior (Twig filters, CmsApi methods, routing, etc.), the web-base path can be obtained from the plugin settings. Do NOT modify web-base files — they are shared across all projects.
|
||||
The web-base path can be obtained via: `GET http://localhost:9090/api/web-base-path`
|
||||
|
||||
Do NOT modify web-base files — they are shared across all projects.
|
||||
|
||||
## Critical Rules
|
||||
|
||||
1. Only edit `index-base.tpl` in modules — `index.tpl`, `index-twig.tpl`, and `builder.json` are auto-generated
|
||||
2. Use Twig **filters** (with `|`), never Twig functions
|
||||
3. Table names without `cms_` prefix everywhere
|
||||
4. Primary key is `num`, never `id`
|
||||
5. Upload fields are arrays — access with `[0].urlPath`
|
||||
6. Tailwind CSS as primary styling, custom CSS scoped with BEM when needed
|
||||
7. Twig concatenation uses `~` operator: `'value=' ~ variable`
|
||||
8. `enlace` (link) fields already include slashes
|
||||
|
||||
## Documentation
|
||||
|
||||
- [docs/modular-system.md](docs/modular-system.md) — Modules, general sections, Twig syntax, builder vars, custom filters
|
||||
- [docs/hooks-and-api.md](docs/hooks-and-api.md) — PHP hooks, CmsApi, CocoDB, database operations
|
||||
- [docs/modular-system.md](docs/modular-system.md) — Modules, general sections, global variables
|
||||
- [docs/builder-fields.md](docs/builder-fields.md) — Builder field types, c-form, c-if/c-for/c-class, data-field-type
|
||||
- [docs/twig-filters.md](docs/twig-filters.md) — Twig filters reference (get, hook, module, queryDB, etc.)
|
||||
- [docs/hooks-and-api.md](docs/hooks-and-api.md) — PHP hooks, CmsApi, CocoDB, database operations
|
||||
- [docs/css-js-conventions.md](docs/css-js-conventions.md) — CSS/JS patterns, Tailwind, BEM, Vue 3 integration
|
||||
|
||||
Reference in New Issue
Block a user