Placeholders Endpoints¶
The Placeholders endpoints provide placeholder content in django CMS.
Used to retrieve content from placeholders object linked to a specific page
This essentially returns all plugins in a placeholder as a nested JSON tree according to the defined placeholders in CMS_PLACEHOLDER_CONF
The content is rendered as HTML if the
?html=1parameter is added to the API URL using Django CMS template renderingSerialized content is either using
ModelSerializeras a default or aCustomSerializerdefined in your plugins configuration
CMS Reference¶
Endpoints¶
Retrieve Placeholder¶
GET /api/{language}/placeholders/{content_type_id}/{object_id}/{slot}/
Placeholder contain the dynamic content. This view retrieves the content as a structured nested object. You can get a direct link to build the query or all attributes from the Pages.
Response Attributes:
slot: The slot name of the placeholder.label: The verbose name of the placeholder.language: The language of the returned content.content: The content rendered as Serialized JSON.html: Optional: The content rendered as HTML.
Note
Use ?html=1 to get the content rendered as HTML.
Path Parameters:
language(string, required): Language code (e.g., “en”, “de”)content_type_id(integer, required): Content type IDobject_id(integer, required): Object IDslot(string, required): Placeholder slot name (e.g., “content”, “sidebar”)
Query Parameters:
html(integer, optional): Set to 1 to include HTML rendering in responsepreview(boolean, optional): Set to true to preview unpublished content (admin access required)
Note
Use ?preview=true has no effect when retrieving the content of a draft page, because we already query the draft content.
Example Request:
GET /api/en/placeholders/5/9/content/?html=1
Example Response:
{
"slot": "content",
"label": "Content",
"language": "en",
"content": [
{
"plugin_type": "TextPlugin",
"body": "<p>Hello World!</p>",
"json": {
"type": "doc",
"content": [
{
"type": "paragraph",
"attrs": {
"textAlign": "left"
},
"content": [
{
"text": "Hello World!",
"type": "text"
}
]
}
]
},
"rte": "tiptap"
}
],
"details": "http://localhost:8080/api/en/placeholders/5/9/content/?html=1",
"html": "<p>Hello World!</p>"
}