markwalker_
markwalker_

Reputation: 12859

Django-CMS apphooked templates showing same placeholder content

I've got a django-cms site on which I have created a page at /managers-home/ with an app hook so that I can use myapp from that page.

myapp renders various templates at various URLs beneath /managers-home/ and I would like each of these templates to have a section editable via the django-cms content plugin. Therefore I have added {% staticplaceholder "content" site %} to these templates, because, as I understand it, you can't use a standard {% placeholder "" %} from within a hooked application.

I made a start with this and added some text to the placeholder on /managers-home/page-1/ which uses page-1.html and then when I got to the placeholder on /managers-home/page-2 I could already see the content from page-1 despite now using page-2.html so the placeholder on these two individual templates is being shared.

How can I correctly add django-cms placeholders throughout my application templates?

Upvotes: 1

Views: 827

Answers (1)

markwalker_
markwalker_

Reputation: 12859

Turns out my problem was that a static_placeholder is exactly that, just a placeholder identified by the name given and anywhere you reference that name you get the same content.

So in order to allow each of my templates to display custom text, I've created a static_placeholder for each template.

# page-1.html
{% static_placeholder "page-1" site or %}
    Default text goes here
{% endstatic_placeholder %}

# settings.py
CMS_PLACEHOLDER_CONF = {
    'page-1': {
        'plugins': ['TextPlugin', 'UploadedPicturePlugin'],
        'text_only_plugins': ['LinkPlugin'],
        'extra_context': {"width": 640},
        'name': gettext("Content"),
    }
}

Upvotes: 2

Related Questions