Skip to content
Snippets Groups Projects
Commit c169d17e authored by Dylann Cordel's avatar Dylann Cordel :crossed_swords:
Browse files

templating

parent 35905c27
No related branches found
No related tags found
No related merge requests found
......@@ -27,7 +27,7 @@ INSTALLED_APPS = [
CMS_HIGHLIGHTED_CONTENT_ITEMS_MODELS = (
# format: ('app_name', ('SomeModel', 'AnOther', )),
('news', ('News', ),),
('fosm', ('Chronicle', 'Note', 'Dossier', 'Conference')),
('fosm', ('Project', 'Event', 'News')),
)
```
......
......@@ -53,6 +53,7 @@ class HighlightedContentPluginBase(CMSPluginBase):
def render(self, context, instance, placeholder):
items = self.get_items(context, instance, placeholder)
context.update({
'title': instance.title,
'object_list': items,
'count': (items.count() if hasattr(items, 'count') and callable(items.count)
else len(items)),
......
......@@ -107,8 +107,8 @@ class HighlightedContentItemBase(models.Model):
def get_template(self):
"""returns the template to use to render this item as a item"""
if self.content_type_id not in self._templates:
kwargs = {'app_label': self._meta.app_label,
'model_name': self._meta.model_name}
kwargs = {'app_label': self.content_type.app_label,
'model_name': self.content_type.model}
templates = ['%(app_label)s/%(model_name)s/highlighted_content_item.html' % kwargs,
'%(app_label)s/highlighted_content_item.html' % kwargs,
'cms_highlighted_content/highlighted_content_item.html']
......
{% load i18n sekizai_tags static %}
{% if items_count %}
<section id="highlighted_content_{{ instance.pk }}" class="mod__highlighted_content" role="region" data-highlighted_content="{{ highlighted_content_opts }}" {% if title %} aria-labelledby="highlighted_content_{{ instance.pk }}_heading"{% endif %}>
{% if title %}<h1 id="highlighted_content_{{ instance.pk }}_heading">{{ title }}</h1>{% endif %}
<div class="viewport">
<ul class="overview">
{% for item in items %}
<li class="item {{ item.content_type.app_label }}_{{ item.content_type.model }}" aria-label="{{ item }}">{% include item.get_template with item=item %}</li>
{% load i18n %}
{% if count %}
<section class="mod__highlighted_content">
{% block highlighted_list_header %}
{% if instance.title %}
<h1>
{% if instance.page_link %}
<a href="{{ instance.page_link.get_absolute_url }}">{{ instance.title }}</a>
{% else %}
{{ instance.title }}
{% endif %}
</h1>
{% endif %}
{% endblock %}
{% block highlighted_list %}
<div class="list">
{% for highlighted_item in object_list %}
{% block highlighted_list_item %}
{% include highlighted_item.get_template with highlighted_item=highlighted_item object=highlighted_item.item %}
{% endblock %}
{% endfor %}
</ul>
</div>
</div>
{% endblock %}
</section>
{% else %}
{% block highlighted_no_object %}{% endblock %}
{% endif %}
<script type="text/javascript">
window.highlighted_contents = [] || window.highlighted_contents ;
window.highlighted_contents.push('#highlighted_content_{{ instance.pk }}');
</script>
{% load static %}
<article>
<h1 class="title">{{ object }}</h1>
<img class="background" src="https://durian.blender.org/wp-content/uploads/2010/05/3.2d.png" alt="" />
<p class="summary">
This is a sample template you should override.
In this exemple, we use an IMG tag to display the image of the item.
</p>
</article>
{% comment %}
<article style="background-image: url('https://durian.blender.org/wp-content/uploads/2010/05/3.2d.png');">
<h1 class="title">{{ object }}</h1>
<p class="summary">This is an other sample template with the image as background.</p>
</article>
<div>
<h1 class="title">{{ object }}</h1>
<video src="http://mirrorblender.top-ix.org/movies/sintel-1024-surround.mp4" autoplay poster="https://durian.blender.org/wp-content/uploads/2010/05/3.2d.png">
<a href="http://mirrorblender.top-ix.org/movies/sintel-1024-surround.mp4" download="sintel-1024-surround.mp4">
<div class="{{ highlighted_item.content_type.model }}">
{% with object.get_absolute_url as url %}
{% block highlighted_item_header %}
<header>
{% block highlighted_item_header_content %}
{% if url %}
<h2><a href="{{ url }}">{{ highlighted_item }}</a></h2>
{% else %}
<h2>{{ highlighted_item }}</h2>
{% endif %}
{% endblock %}
</header>
{% endblock %}
<div>
{% block highlighted_item_body_content %}
<img class="background" src="https://durian.blender.org/wp-content/uploads/2010/05/3.2d.png" alt="" />
</a>
</video>
<p class="summary">Another exemple with a video.</p>
<p class="summary">
This is a sample template you should override.
In this exemple, we use an IMG tag to display the image of the item.
</p>
{% endblock %}
</div>
{% endwith %}
</div>
{% endcomment %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment