Brandon Taylor
Brandon Taylor

Reputation: 34583

Django CMS template inheriting from ancestor not recognizing placeholder

I'm using Django CMS 3.0.13. I have a page connected to an App Hook that inherits its template from the nearest ancestor.

The ancestor template is not connected to an App Hook, and has a placeholder:

{# ancestor template #}
{% block content %}
    {% placeholder 'content' %}
{% endblock %}

The App Hook page was previously overriding this block to hide the content placeholder. Now, I need to enable this placeholder, so I removed the override and am greeted with:

"content" placeholder not found in an apphook application. Please use a static placeholder instead.

I have tried:

All of which result in the same error. The only thing I have found that will resolve this is to add a specific page for the App Hook'ed page to CMS_TEMPLATES.

This is less than ideal. What can I do to work around this?

Upvotes: 0

Views: 617

Answers (1)

markwalker_
markwalker_

Reputation: 12859

The placeholder tag has to be used on pages directly tied to CMS pages. If your template is rendered via a django app, you need to use static_placeholder.

A static_placeholder can also be used to re-use the same content between templates e.g. a footer.

Docs on static placeholders in terms of their use within CMS pages and not external apps; http://django-cms.readthedocs.org/en/latest/how_to/templates.html#static-placeholder

Also, if you've not explored this, then take a look at the docs around placeholders in your apps. http://django-cms.readthedocs.org/en/latest/how_to/placeholders.html

Using a PlaceholderField in your apps can lead to some cool app hooks which can take all your CMS plugins. Specifically I've made a news app with those that allows you to add/edit content via the toolbar, then have a ListView page for all the objects which renders out the placeholder fields in the corresponding DetailView.

Upvotes: 1

Related Questions