I am creating a django-cms site for a client. I would like to do something like:
Great answer Flimm, thanks!
I get an error, however, in the context processor saying that a CMSPlugin
object does not have a filerimage
attribute. Here's the context processor that works for me:
# in context_processors.py
from cms.models.pluginmodel import CMSPlugin
def cover_image(request):
page = request.current_page
if page:
cover_image_plugin = CMSPlugin.objects.filter(
placeholder__page=page,
placeholder__slot='cover_image',
plugin_type='FilerImagePlugin',
).first()
if cover_image_plugin:
return {'cover': cover_image_plugin.get_plugin_instance()[0]}
return {}
Note the change in the but last line. get_plugin_instance
retrieves the rightly subclassed instance object as the first entry of a tuple. (I use Django CMS 3.4)
As a last remark, the cover_image
placeholder needs to be in a place that is not rendered.