Create Section
How to create a new section.
Ensure to have read and write permissions.
You'll need to supply a list of parameters whose name matches the name of the section elements. For each element, you should give a value accordingly, or else the field would remain empty.
This API accepts an arbitrary number of parameters.
You'll always need to supply the locale in the elements key, even if your project has the Multi-language feature disabled.
For example, if you wish to populate a section that has the following elements:
- Title
- Description
- Image
- Link
The list of parameters for a single locale (for example, Italian
[it]
) should be:elements[it][title]
elements[it][description]
elements[it][image][0]
elements[it][link]
As you can see, every key of an element must be in the form of
🔹
elements[LOCALE][ELEMENT_NAME]
As you can see, every key of a media element (image, audio, video, document, file) must be in the form of
🔹
elements[LOCALE][ELEMENT_NAME][INDEX]
Even if you add just a single image to a media element, it will always be considered as an array.
Instead relation elements doesn't require a locale so the key must be in the form of
🔹
relation[BLOCK_INDEX]
This API assigns the section creator based on which auth headers are present. If the mobile auth header is present the creator is the mobile user, otherwise it will be assigned to project.
Request
Response
POST https://mburger.cloud/api/blocks/<id>/sections
curl https://mburger.cloud/api/blocks/<id>/sections
-X POST
-H "Accept: application/json"
-H "Content-Type: application/x-www-form-urlencoded"
-H "X-MBurger-Token: <token>"
-H "X-MBurger-Version: 3"
-d '<data>'
Name | Type | Required | Description |
id | int | Yes | Block id |
The parameters to create a section will depend on which elements the section is made of and how many locales are present.
Name | Type | Required | Description |
order | int | No | To specify an order |
evidence | boolean | No | Enable in_evidence flag |
elements | array | Yes | An Array of block's elements |
If evidence is true, is possible to set other two parameters:
Name | Type | Required | Description |
evidence_title | int | No | To specify an order |
evidence_image | boolean | No | Enable in_evidence flag |
When successful, a HTTP 200 and JSON like this is returned:
{
"status_code": 0,
"body": {
"id": 2,
"order": 1,
"all_locales": true,
"visible": true,
"in_evidence": false,
"available_at": 1548343787,
"updated_at": 1548343787
}
}
Last modified 2yr ago