Introduction
Attributes are an entity that allows you to configure the structure of your application. With them, you can achieve maximum flexibility and eliminate hardcoding.
Attribute sets are similar to a collection of properties, the values of which you can manage through the admin panel. They differ in the type of binding to various entities. You can read more about the types in the section "Types".
An attribute set forms the data structure that can then be used within your project. For example, for a product, you can define that its structure should include a name, image, price, and text description. At the same time, the structure of a blog post may contain text with a title and a set of images.
Some attributes may have similar structures and be used in different entities, so you can reuse attribute sets for different entities.
Structure
Each attribute set contains a customizable collection of attributes that store the content of your project. You can manage these attributes from the management system. This is convenient, as you no longer need to edit the application code to change your project. Just move all content components that can be changed into attributes.
Markers cannot contain spaces and cannot start with a digit. If you try to enter invalid values in the marker field, the system will ignore the input.
Name
To make it easier for you to navigate, each attribute has a required name parameter, which is a non-unique string. Name your attributes in a way that makes it easy for you to work with them.
Marker
As an identifier, each attribute has a required parameter - "marker," which is a unique string. The marker is also used as a key to access the attributes in your project's code. Keep this in mind when setting the attribute marker to avoid syntax conflicts.
Data Type
Choose a data type for each attribute field that it will store.
Data types can be of the following types:
- String: Simple text, for example, "Hello, world!".
- Text: Longer text, often formatted, such as an article or letter.
- Text with Header: Text with a header that can be used to denote a topic or category.
- Integer: Whole number, for example, 5, 100, -2.
- Float: Data type for floating-point numbers that can have a decimal part, for example, 3.14, 1.5, -0.25.
- Real: Same as Float, but with higher precision.
- Date and Time: Combination of date and time, for example, 2023-10-27 10:00:00.
- Date: Date, for example, 2023-10-27.
- Time: Time, for example, 10:00:00.
- File: Any file on your computer, such as a document, image, or music.
- Image: An image, for example, a photograph or drawing.
- Group of Images: A collection of images, for example, a photo album.
- Radio Button: A selection button from which only one option can be chosen.
- List: A list of items, for example, a list of product sizes.
- Entity: An entity representing a real-world object, such as a person, place, or organization.
- JSON: Stores data in JSON format.
The content filling interface will correspond to the selected data type for each attribute field.
Opportunities
You can add validators for attributes. This mechanism is discussed in more detail in the section "Validators".
If one attribute set is used by multiple entities at the same time, you need to be careful when changing the attributes of that set. For example, if you delete one of the attributes, that attribute will be removed everywhere it is used along with its content. If you add a new attribute to the set, that attribute will also be added everywhere the attribute set is used.