Banner images display
This commit is contained in:
parent
80c0951a5e
commit
2a2eca14f3
4 changed files with 58 additions and 18 deletions
|
@ -21,8 +21,18 @@ class ArticleIndexPage(Page):
|
||||||
'title',
|
'title',
|
||||||
'title_fr',
|
'title_fr',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
intro_de = RichTextField(default='', blank=True)
|
||||||
|
intro_fr = RichTextField(default='', blank=True)
|
||||||
|
trans_intro = TranslatedField(
|
||||||
|
'intro_de',
|
||||||
|
'intro_fr',
|
||||||
|
)
|
||||||
|
|
||||||
content_panels = Page.content_panels + [
|
content_panels = Page.content_panels + [
|
||||||
|
FieldPanel('intro_de'),
|
||||||
FieldPanel('title_fr'),
|
FieldPanel('title_fr'),
|
||||||
|
FieldPanel('intro_fr'),
|
||||||
]
|
]
|
||||||
def get_context(self, request):
|
def get_context(self, request):
|
||||||
context = super(ArticleIndexPage, self).get_context(request)
|
context = super(ArticleIndexPage, self).get_context(request)
|
||||||
|
@ -39,8 +49,8 @@ class ArticlePage(Page):
|
||||||
'title_fr',
|
'title_fr',
|
||||||
)
|
)
|
||||||
|
|
||||||
intro_de = RichTextField(default='')
|
intro_de = RichTextField(default='', blank=True)
|
||||||
intro_fr = RichTextField(default='')
|
intro_fr = RichTextField(default='', blank=True)
|
||||||
trans_intro = TranslatedField(
|
trans_intro = TranslatedField(
|
||||||
'intro_de',
|
'intro_de',
|
||||||
'intro_fr',
|
'intro_fr',
|
||||||
|
@ -61,7 +71,6 @@ class ArticlePage(Page):
|
||||||
'body_fr',
|
'body_fr',
|
||||||
)
|
)
|
||||||
|
|
||||||
date = models.DateField("Date")
|
|
||||||
feed_image = models.ForeignKey(
|
feed_image = models.ForeignKey(
|
||||||
'wagtailimages.Image',
|
'wagtailimages.Image',
|
||||||
null=True,
|
null=True,
|
||||||
|
@ -91,7 +100,6 @@ class ArticlePage(Page):
|
||||||
], heading="Français"),
|
], heading="Français"),
|
||||||
]
|
]
|
||||||
promote_panels = [
|
promote_panels = [
|
||||||
FieldPanel('date'),
|
|
||||||
ImageChooserPanel('feed_image'),
|
ImageChooserPanel('feed_image'),
|
||||||
InlinePanel('related_links', label="Links"),
|
InlinePanel('related_links', label="Links"),
|
||||||
MultiFieldPanel(Page.promote_panels, "Common page configuration"),
|
MultiFieldPanel(Page.promote_panels, "Common page configuration"),
|
||||||
|
@ -125,8 +133,8 @@ class HomePage(Page):
|
||||||
'intro_fr',
|
'intro_fr',
|
||||||
)
|
)
|
||||||
|
|
||||||
body_de = RichTextField(default='')
|
body_de = RichTextField(default='', blank=True)
|
||||||
body_fr = RichTextField(default='')
|
body_fr = RichTextField(default='', blank=True)
|
||||||
trans_body = TranslatedField(
|
trans_body = TranslatedField(
|
||||||
'body_de',
|
'body_de',
|
||||||
'body_fr',
|
'body_fr',
|
||||||
|
@ -143,14 +151,30 @@ class HomePage(Page):
|
||||||
'infos_fr',
|
'infos_fr',
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_articles(self):
|
|
||||||
return ArticleIndexPage.objects.descendant_of(self).live().order_by('-date').select_related('owner')
|
|
||||||
|
|
||||||
content_panels = Page.content_panels + [
|
content_panels = Page.content_panels + [
|
||||||
FieldPanel('intro_de', classname="full"),
|
MultiFieldPanel([
|
||||||
FieldPanel('intro_fr', classname="full"),
|
FieldPanel('intro_de', classname="full"),
|
||||||
FieldPanel('body_de', classname="full"),
|
FieldPanel('body_de', classname="full"),
|
||||||
FieldPanel('body_fr', classname="full"),
|
StreamFieldPanel('infos_de'),
|
||||||
StreamFieldPanel('infos_de'),
|
], heading="Deutsch"),
|
||||||
StreamFieldPanel('infos_fr'),
|
MultiFieldPanel([
|
||||||
|
FieldPanel('intro_fr', classname="full"),
|
||||||
|
FieldPanel('body_fr', classname="full"),
|
||||||
|
StreamFieldPanel('infos_fr'),
|
||||||
|
], heading="Français"),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@property
|
||||||
|
def featured(self):
|
||||||
|
# Get list of live pages that are descendants of this page
|
||||||
|
articles = ArticlePage.objects.live().descendant_of(self)
|
||||||
|
# Order by most recent date first
|
||||||
|
#articles = articles.order_by('-date')
|
||||||
|
return articles
|
||||||
|
|
||||||
|
def get_context(self, request):
|
||||||
|
featured = self.featured[:4]
|
||||||
|
# Update template context
|
||||||
|
context = super(HomePage, self).get_context(request)
|
||||||
|
context['featured'] = featured
|
||||||
|
return context
|
|
@ -1,15 +1,19 @@
|
||||||
{% load wagtailcore_tags %}
|
{% load wagtailcore_tags %}
|
||||||
|
{% load wagtailimages_tags %}
|
||||||
|
|
||||||
<div id="carousel-banner" class="slide">
|
<div id="carousel-banner" class="slide">
|
||||||
<div class="carousel-inner slick" role="listbox">
|
<div class="carousel-inner slick" role="listbox">
|
||||||
{% for entry in articles %}
|
{% for entry in featured %}
|
||||||
<div class="item">
|
<div class="item">
|
||||||
<image style="background-image:url({{ entry.feed_image.src }})" />
|
{% image entry.feed_image original as entry_photo %}
|
||||||
|
<image style="background-image:url({{ entry_photo.url }})">
|
||||||
<div class="carousel-caption">
|
<div class="carousel-caption">
|
||||||
<h3>{{ entry.trans_title }}</h3>
|
<h3>{{ entry.trans_title }}</h3>
|
||||||
<p>{{ entry.trans_intro|richtext }}</p>
|
<p>{{ entry.trans_intro|richtext }}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{% empty %}
|
||||||
|
No articles found
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
</div><!-- /carousel-banner -->
|
</div><!-- /carousel-banner -->
|
||||||
|
|
|
@ -4,5 +4,15 @@
|
||||||
{% block body_class %}template-{{ self.get_verbose_name|slugify }}{% endblock %}
|
{% block body_class %}template-{{ self.get_verbose_name|slugify }}{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
...
|
{% for entry in banner_articles %}
|
||||||
|
<div class="item">
|
||||||
|
<image style="background-image:url({{ entry.feed_image.src }})" />
|
||||||
|
<div class="carousel-caption">
|
||||||
|
<h3>{{ entry.trans_title }}</h3>
|
||||||
|
<p>{{ entry.trans_intro|richtext }}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% empty %}
|
||||||
|
No articles found
|
||||||
|
{% endfor %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
{% include 'news.html' %}
|
{% include 'news.html' %}
|
||||||
|
|
||||||
<!-- Page body -->
|
<!-- Page body -->
|
||||||
|
{% if page.trans_body %}
|
||||||
<section>
|
<section>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="homepage-body">
|
<div class="homepage-body">
|
||||||
|
@ -20,6 +21,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<!-- Infoblocks -->
|
<!-- Infoblocks -->
|
||||||
<section id="three" class="wrapper align-center">
|
<section id="three" class="wrapper align-center">
|
||||||
|
|
Loading…
Reference in a new issue