Guide: Understanding and Creating Modules
Modules are the building blocks of your website. They allow you to add features, manage content, and organize functionality in a structured way. This guide will teach you how to create and configure modules, including fields, relationships, and fields validations, step by step.
1. What is a Module?
A module represents a specific feature or functionality on your website. Examples include:
- Blog posts
- Product catalogs
- Contact forms
- User profiles
Each module can contain:
- Fields: The data points or inputs you want to capture (e.g., title, description, image).
- Relationships: Connections to other modules for dynamic content (e.g., a blog post linked to categories or authors).
Modules are reusable and can be updated or extended without affecting other parts of the website.
2. Key Features of a Module
-
Fields
Fields define what information your module will store. Each field has:- Field Name: The label that identifies the field.
- Field Type: Type of data (text, number, image, date, select, etc.).
- Required / Optional: Whether the field must be filled in.
- Default Value: Optional pre-filled value for convenience.
Example:
A “Blog Post” module might have:Field Name Type Required Default Title Text Yes - Content Rich Text Yes - Featured Image Image No - Published Date Date No Today
3 Relationships
Relationships connect one module to another, allowing you to link data dynamically.
- One-to-One: Each item connects to a single item in another module (e.g., a user profile to a single role).
- One-to-Many: Each item connects to multiple items in another module (e.g., a category having many blog posts).
- Many-to-Many: Items can connect to multiple items in both directions (e.g., products linked to multiple tags).
Example:
Linking a “Blog Post” module to a “Category” module:
- Each blog post belongs to one category.
- A category can contain many blog posts.
This allows you to filter, sort, and display content dynamically across your website.
4. Editing a Module
To update an existing module:
- Go to the Modules list.
- Click Edit next to the module name.
- Update fields, relationships as needed.
- Save changes.
Tip: Changes to a module do not affect previously created content unless explicitly updated.
5. Best Practices
- Descriptive Names: Use clear and meaningful names for modules and fields.
- Plan Relationships: Define relationships before creating content to avoid data issues.
- Keep It Simple: Only add fields that are necessary.
- Test New Modules: Preview the module before using it live.
6. Example Workflow
- Create a Category module with a
Namefield. - Create a Blog Post module with fields:
Title,Content,Featured Image. - Add a Relationship from Blog Post → Category (one-to-many).
- Save and start adding content.
Now, your blog posts are connected to categories, and you can display dynamic content on your website effortlessly.
Next Steps: After learning modules, proceed to Routes and Hooks & Actions to connect and trigger modules dynamically.