Skip to content

Commit

Permalink
Merge pull request #146 from springload/feat/auto-landing-listing
Browse files Browse the repository at this point in the history
Add an automatic child listing to section landing pages
  • Loading branch information
liamjohnston authored Jul 25, 2024
2 parents deba821 + 00174ae commit a021d51
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 8 deletions.
6 changes: 6 additions & 0 deletions cdhweb/pages/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,12 @@ class BaseLandingPage(BasePage, StandardHeroMixin):

search_fields = StandardHeroMixin.search_fields + [index.SearchField("body")]

def get_context(self, request):
ctx = super().get_context(request)

ctx["children"] = self.get_children().live().public().filter(show_in_menus=True)
return ctx

class Meta:
abstract = True

Expand Down
13 changes: 12 additions & 1 deletion templates/cdhpages/landing_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,21 @@
page-layout--with-sidenav
{% else %}
page-layout--without-sidenav
{% endif %}
{% endif %}
">
<div class="page-layout__main-content">

<div class="streamfields-wrapper">
{% if children %}
<div class="block block--tiles">
<div class="tiles__list">
{% for child in children %}
{% include 'cdhpages/blocks/tile.html' with internal_page=child tile_type="internal_page_tile" has_component_title=False %}
{% endfor %}
</div>
</div>
{% endif %}

{% for block in page.body %}
{% include_block block %}
{% endfor %}
Expand Down
10 changes: 6 additions & 4 deletions templates/people/people_category_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@
<div class="page-layout__main-content">
<div class="streamfields-wrapper">
{% if people %}
<div class="tiles__list">
{% for person in people %}
{% include 'cdhpages/blocks/person_tile.html' %}
{% endfor %}
<div class="block block--tiles">
<div class="tiles__list">
{% for person in people %}
{% include 'cdhpages/blocks/person_tile.html' %}
{% endfor %}
</div>
</div>
{% endif %}

Expand Down
6 changes: 3 additions & 3 deletions templates/people/person_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
{% endfor %}

{% if recent_projects %}
<div class="block-tile_block">
<div class="block block--tiles">
<div class="tiles__title-wrapper">
<h2>Recent projects</h2>
</div>
Expand All @@ -27,7 +27,7 @@ <h2>Recent projects</h2>
{% endif %}

{% if recent_events %}
<div class="block-tile_block">
<div class="block block--tiles">
<div class="tiles__title-wrapper">
<h2>Recent events</h2>
</div>
Expand All @@ -41,7 +41,7 @@ <h2>Recent events</h2>

{# TODO - when blog page exists #}
{% if recent_posts %}
<div class="block-tile_block">
<div class="block block--tiles">
<div class="tiles__title-wrapper">
<h2>Recent posts</h2>
</div>
Expand Down

0 comments on commit a021d51

Please sign in to comment.