0

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 %}
user14412
  • 987
  • 1
  • 11
  • 32
  • Did you try `{% show_placeholder "footer_info" "home_cms_page" %}` (with quotes)? – Bernhard Vallant Aug 19 '12 at 09:55
  • Yes, I tried almost everything I can think of. With quotes, without quotes, with template name, with page-id, there's still no contents from home showing up on services page. Is my setup incorrect in any way? I put the placeholder footer_info in base.html (without quotes, I think quotes don't really matter based on my experiments), add some contents to the footer_info placeholder in home_cms_page from the admin area, then in the template for services I put in the snippet above. – user14412 Aug 19 '12 at 17:39
  • Is thisa multilingual site? Maybe it's helpful if you can show the whole relevant templates... – Bernhard Vallant Aug 19 '12 at 18:28
  • In one template you have `{% placeholder "footer_info" or %}` and in the other `{% placeholder footer_info %}` which should be something different, also can't really tell from your postings how you wrapped your footer in django's `{% block .... %}`... – Bernhard Vallant Aug 19 '12 at 19:55
  • By "something" different, do you mean I need to get rid of the quotes in base.html? I tried that already. If that's not what you meant, then I assume you are saying it needs to have a different name like placeholder services_info. I tried that as well. Also, I didn't wrap the placeholder in a block tag. – user14412 Aug 19 '12 at 21:43
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/15545/discussion-between-user14412-and-bernhard-vallant) – user14412 Aug 20 '12 at 00:37
  • I know this is an old post, but did you publish the content added to footer_info on your home page? Also, I had to put quotes around "footer_info" and "home_cms_page". It is working for me. – Nostalg.io Oct 09 '14 at 07:18
  • @halfnibble, it is indeed an old post, and I don't even remember what I did with that project... but thanks so much for your help despite that the post is old :) – user14412 Oct 11 '14 at 04:15

1 Answers1

3

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.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Anshik
  • 46
  • 2
  • There is a problem with show_placeholder. When you are using the front-end edition mode and publish from there, it doesn't publish the changes on the showed placeholder because it belong to another page. – toto_tico Mar 22 '14 at 08:57