Working with templates

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

static_placeholder

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

CMS_TEMPLATE

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

  1. {% load cms_tags %}
  2. <html>
  3. <body>
  4. {% cms_toolbar %}
  5. {% block main %}
  6. {% placeholder "main" %}
  7. {% endblock main %}
  8. </body>
  9. </html>

Example: application template

  1. {% extends CMS_TEMPLATE %}
  2. {% load cms_tags %}
  3. {% block main %}
  4. {% for item in object_list %}
  5. {{ item }}
  6. {% endfor %}
  7. {% static_placeholder "sidebar" %}
  8. {% endblock main %}

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

render_model

New in version 3.0.

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