ic-labs / django-icekit

GLAMkit is a next-generation Python CMS by the Interaction Consortium, designed especially for the cultural sector.
http://glamkit.com
MIT License
47 stars 11 forks source link

Placeholder slots cannot be defined programmatically #290

Open markfinger opened 7 years ago

markfinger commented 7 years ago

Fluent allows you to define placeholder slots via the get_placeholder_data hook on the admin class responsible for a page type. Unfortunately, the layout pages have a add_missing_placeholders hack that overrides it.

Background:

mark 
[9:46 AM] 
Does anyone know how to explicitly add placeholders to a page without relying on the `{% page_placeholder ... %}` being picked up?

Use-case is a placeholder that needs manual iteration of the content items to render a complicated grid layout. I'd prefer not bundle the grid markup and parent-introspection into the content item's template.

mark
[2:47 PM] 

Turns out that icekit prevents this from functioning.

You can define `get_placeholder_data` on a page type's `model_admin` class, but icekit's layout model will still defer to the rendered template.

This seems to be related to the `add_missing_placeholders` hack, which was added to handle additions of placeholders after a page had already been defined.

My hacky workaround is to call the `page_placeholder` tag, but wrap it in a HTML comment and then manually iterate over the child plugin instances.

james [2:50 PM] 
@mark I resorted to a similar nasty hack here: https://github.com/ixc/agsa/blob/develop/tarnanthi/templates/tarnanthi/layouts/event.html#L118 -- use the `page_placeholder` template tag, but tell it to render an empty HTML template (edited)

mark
[2:51 PM] 
Cool, your workaround saves rendering the plugin instances

james [2:52 PM] 
I was hoping you'd find the "There must be a better way" part of my TODO there...

mark
[2:52 PM] 
Yeah, similarly.

[2:53] 
I knew that I had previously found a workaround for this, but it looks like changes have occurred in icekit since then and there's no longer a reasonable way to do it.
markfinger commented 7 years ago

cc @jmurty