How to work with templates

Application can reuse cms templates by mixing cms template tags and normal django templating language.


Plain placeholder cannot be used in templates used by external applications, use static_placeholder instead.


New in version 3.0.

CMS_TEMPLATE is a context variable available in the context; it contains the template path for CMS pages and application using apphooks, and the default template (i.e.: the first template in CMS_TEMPLATES) for non-CMS managed URLs.

This is mostly useful to use it in the extends template tag in the application templates to get the current page template.

Example: cms template

{% load cms_tags %}
    {% cms_toolbar %}
    {% block main %}
    {% placeholder "main" %}
    {% endblock main %}

Example: application template

{% extends CMS_TEMPLATE %}
{% load cms_tags %}
{% block main %}
{% for item in object_list %}
    {{ item }}
{% endfor %}
{% static_placeholder "sidebar" %}
{% endblock main %}

CMS_TEMPLATE memorises the path of the cms template so the application template can dynamically import it.


New in version 3.0.

render_model allows to edit the django models from the frontend by reusing the django CMS frontend editor.