user14412
user14412

Reputation: 1017

Django-CMS show_placeholder not working as expected

I'm working on a site where the footer content is shared across all pages. What is the best way to do in Django-CMS?

I tried using show_placeholder tag, but it somehow didn't work. A little more details on what I did:

First, I have a {% placeholder footer_info %} in base.html. Then I add a page called "Home" (template homepage.html) in django admin and put some text under footer_info as a Text plugin. As the accepted answer in this question suggested (http://stackoverflow.com/questions/3616745/how-to-render-django-cms-plugin-in-every-page),

I add

{% placeholder footer_info or %}
{% show_placeholder footer_info "Home" %}
{% endplaceholder %}

In a template called services.html which I used as the template for page Services. However, the content in home page is not showing up in services page. I also tried adding an id home_cms_page to home page in the Advanced option area, so that I can reference it in services.html like this:

{% placeholder footer_info or %}
{% show_placeholder footer_info "home_cms_page" %}
{% endplaceholder %}

But the content is still not showing up.

Could anyone tell me what I am doing wrong? And is this the best way of getting some content from a page across all other pages (and I have to add show_placeholder in every other page)?

Thank you


EDIT:

It is not a multilingual site. I commented out 'cms.middleware.multilingual.MultilingualURLMiddleware', because the only language I use on the site is English.

I have this in my base.html:

{% load cms_tags sekizai_tags %}

<!-- all the rest of the HTML markups -->

<div class="span4">

{% placeholder footer_info %}

</div>

Then I added a page in the admin called "Home" with a Text plugin and an id of "home_cms_page".

The following is in my services.html:

{% extends "base.html" %}
{% load cms_tags %}

{% block base_content %}
    {% placeholder services_info %}
{% endblock base_content %}

{% block page_content %}
<a href="{% page_url "home_cms_page" %}">Home page</a>
{% endblock page_content %}

{% placeholder "footer_info" or %}
{% show_placeholder "footer_info" "home_cms_page" %}
{% endplaceholder %}

Upvotes: 0

Views: 1977

Answers (1)

Anshik
Anshik

Reputation: 46

Read the documentation:

If you know the exact page you are referring to, it is a good idea to use a reverse_id (a string used to uniquely name a page) rather than a hard-coded numeric ID in your template. For example, you might have a help page that you want to link to or display parts of on all pages. To do this, you would first open the help page in the admin interface and enter an ID (such as help) under the ‘Advanced’ tab of the form. Then you could use that reverse_id with the appropriate templatetags: {% show_placeholder "right-column" "help" %}

I added "index" in the advanced options of the index page, and added {% show_placeholder "banner" "index" %} in the base template. It all works.

Upvotes: 3

Related Questions