aldryn-newsblog icon indicating copy to clipboard operation
aldryn-newsblog copied to clipboard

render_placeholder view.config.placeholder_detail_bottom act as Static Placeholder

Open FabrizioA opened this issue 7 years ago • 5 comments

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.

FabrizioA avatar Apr 15 '17 10:04 FabrizioA

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.

pinksharpii avatar May 01 '17 19:05 pinksharpii

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

dawado avatar May 10 '17 09:05 dawado

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

FabrizioA avatar May 10 '17 10:05 FabrizioA

@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

dawado avatar May 15 '17 09:05 dawado

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?

tramusoft avatar May 31 '18 00:05 tramusoft