Skip to content

Commit

Permalink
Update homepage template to include new content
Browse files Browse the repository at this point in the history
  • Loading branch information
ThatcherK committed Nov 17, 2023
1 parent 4c6de75 commit 78211e7
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 24 deletions.
9 changes: 9 additions & 0 deletions di_website/home/templatetags/content_tags.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from django import template

register = template.Library()


@register.simple_tag
def get_featured_pages(page_blocks):
featured_pages = [block.value for block in page_blocks]
return featured_pages
10 changes: 10 additions & 0 deletions di_website/templates/home/blocks/featured_work.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{% load static wagtailcore_tags card_tags generic_tags content_tags %}

{% get_featured_pages self.featured_pages as featured_pages %}
{% with related_pages=featured_pages heading=self.featured_work_heading %}
{% if self.featured_pages|length == 1 %}
{% include 'home/includes/featured_page.html' %}
{% else %}
{% include 'includes/partials/related_content.html' %}
{% endif %}
{% endwith %}
69 changes: 45 additions & 24 deletions di_website/templates/home/home_page.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends 'layouts/default.html' %}
{% load wagtailcore_tags generic_tags %}
{% load wagtailcore_tags generic_tags content_tags %}


{% block body %}
Expand All @@ -22,30 +22,51 @@
{% include 'includes/heroes/hero.html' %}
{% endif %}


{% if page.featured_content %}
<section class="section">
<div class="row row--narrow">
<div class="l-2up">
{% for block in page.featured_content %}
{% include_block block %}
{% endfor %}
</div>
</div>
</section>
{% endif %}

{% if featured_pages %}
{% with related_pages=featured_pages heading=page.featured_work_heading %}
{% if related_pages|length == 1 %}
{% include 'home/includes/featured_page.html' %}
{% if page.new_content %}
{% for block in page.content %}
{% if block.block_type == 'featured_content' %}
<section class="section">
<div class="row row--narrow">
<div class="l-2up">
{% for item in block.value %}
{% include_block item %}
{% endfor %}
</div>
</div>
</section>
{% elif block.block_type == 'sections' %}
{% for item in block.value %}
{% include_block item %}
{% endfor %}
{% else %}
{% include 'includes/partials/related_content.html' %}
{% include_block block %}
{% endif %}
{% endwith %}
{% endif %}
{% endfor %}
{% else %}
{% if page.featured_content %}
<section class="section">
<div class="row row--narrow">
<div class="l-2up">
{% for block in page.featured_content %}
{% include_block block %}
{% endfor %}
</div>
</div>
</section>
{% endif %}

{% for block in page.sections %}
{% include_block block %}
{% endfor %}
{% if featured_pages %}
{% with related_pages=featured_pages heading=page.featured_work_heading %}
{% if related_pages|length == 1 %}
{% include 'home/includes/featured_page.html' %}
{% else %}
{% include 'includes/partials/related_content.html' %}
{% endif %}
{% endwith %}
{% endif %}

{% for block in page.sections %}
{% include_block block %}
{% endfor %}
{% endif %}
{% endblock body %}

0 comments on commit 78211e7

Please sign in to comment.