Skip to content
This repository has been archived by the owner on Oct 29, 2019. It is now read-only.

render_placeholder view.config.placeholder_detail_bottom act as Static Placeholder #452

Open
FabrizioA opened this issue Apr 15, 2017 · 5 comments

Comments

@FabrizioA
Copy link

Hi,

I'm using {% render_placeholder view.config.placeholder_detail_bottom %} inside article_detail.html template and I have noticed that it is act as a static placeholder, so when I select another article I see the same content added on the other article.

Is there a "placeholder" belongs to an article and that I can use as secondary content placeholder??

Thank you.
F.

@pinksharpii
Copy link

I'm running into a similar issue. I can't see to place a placeholder on the main blog page and have it not render on the detail view of a single blog. I can only place placeholder tags in my blog template file. But if I just put the placeholder tag in the aldryn_newsblog template files, it doesn't display at all.

@dawado
Copy link

dawado commented May 10, 2017

Did you solved it? I have the same problem.
I want to use a placeholder for plugins which are different on each news detail page. @pinksharpii @FabrizioA

@FabrizioA
Copy link
Author

Hi @dawado , I haven't solved it. I don't know if this problem is a bug of a feature....

@dawado
Copy link

dawado commented May 15, 2017

@FabrizioA @pinksharpii

Hey,
i asked @czpython for help and he told me this:

There are different ways to solve this:

One is to override the article detail template and add a static placeholder there.
The declaration of the static placeholder needs to contain something unique to the article, like so:

{% static_placeholder 'article_image_'|add:article.pk %}

This would cause a static placeholder to be created for each article.

Personally, I don't like this approach because it makes use of a technicality within the cms and as such might break in the future.
Plus it binds the data to the template instead of the article itself.

The recommended approach is to create an app in your project with a model that has a one to one relationship to the article
and a placeholder field for the image or other content:

Class ArticleExtension(models.Model):
article = models.OneToOneField(Article, related_name='extension')
image_placeholder = PlaceholderField('article_image')

Then in your template you can do something like:

{% if article.extension %}
{% render_placeholder article.extension.image_placeholder %}
{% endif %}

Its a bit more work than the template based approach but in my opinion is cleaner and more explicit.

Maybe it will helps you.

Greetings Danny

@tramusoft
Copy link

Hi @FabrizioA
I used the second solve but when i add an article the table articleextension dont created an instance for image_placeholder_id, and the placeholder dont appear in structure

Do you solved this?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants