Django-CMS - Global placeholder?

Is there a way to make a global placeholder in a base template? I need everything to be the same on every page (list of banners). How can i do this?

+6
source share
3 answers

I usually create a page in my CMS that is not published, but contains placeholders that I would like to use elsewhere (footer / headers), etc.

Create a new extra_placeholders.html template:

{% extends "base.html" %} {% load cms_tags %} {% block content %} {% placeholder "Banner-List" %} {% endblock %} 

add it to your settings:

 CMS_TEMPLATES = ( ('my/path/extra_placeholders.html', 'Extra Placeholder Page'), ... ) 

now go to admin and create a placeholder with any plugin you want. Then go to the base template ( * base.html ) from which all your other pages are inherited, and add this wherever you want the placeholder to appear:

 {% load cms_tags %} ... {% show_placeholder "Banner-List" "extra_placeholders" %} 

You can learn more about this in the documents.


EDIT

As José L. Patiño noted in the comments, this solution is only necessary for those using django-cms <3.0. For a newer version, you can simply use the static_placeholder tag

+11
source

Now there is "static_placeholders", http://django-cms.readthedocs.org/en/latest/advanced/templatetags.html

It looks like you needed back when.

+5
source

You can use the following methods to create a global controller for all pages.

  • create a place on the main page. {% "Footer" %}
  • make placeholder content via django cms as homepage
  • then, to display the same for each placeholder page, add the footer {% show_placeholder "home"%}, which means displaying the newly created footer placeholder earlier from the home page,
  • This will display the entire contents of the existing replacement footers on the home page of all pages using the template.
  • but for the homepage, two footers will be displayed, to mengilangkannya, please make changes to use CSS to hide the master placeholder.
+1
source

All Articles