divio / aldryn-newsblog

A combined news/weblog application for Aldryn and django CMS – part of the Essential Addons.
https://marketplace.django-cms.org/en/addons/browse/aldryn-newsblog/
Other
67 stars 118 forks source link

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

Open FabrizioA opened 7 years ago

FabrizioA commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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

dawado commented 7 years ago

@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 'articleimage'|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 commented 6 years ago

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?