Skip to content
This repository has been archived by the owner on Feb 27, 2023. It is now read-only.

Commit

Permalink
cms/section_block: add tmplate for section block to remove issues of …
Browse files Browse the repository at this point in the history
…2 block types in structured page
  • Loading branch information
philli-m authored and rmader committed Feb 18, 2021
1 parent 0ec3455 commit a69db99
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 25 deletions.
3 changes: 3 additions & 0 deletions cms/home/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ class SectionBlock(StructBlock):
]
)

class Meta:
template = 'cms_home/blocks/section_block.html'


class ThreeBlogEntriesBlock(StructBlock):
title = CharBlock(required=False,
Expand Down
8 changes: 8 additions & 0 deletions cms/home/templates/cms_home/blocks/section_block.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{% load wagtailimages_tags wagtailcore_tags %}

<div>
<h2>{{ block.value.title }}</h2>
{% for block_content in block.value.content %}
{% include_block block_content %}
{% endfor %}
</div>
37 changes: 12 additions & 25 deletions cms/home/templates/cms_home/structured_text_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,21 @@
{% block content %}
<div class="container structured-page">
<div class="row">
<div class="d-none col-md-3 d-md-block">
<ul id="structured-page-side-nav" class="nav flex-column structured-page-side-nav">
<div class="d-none col-md-3 d-md-block">
<ul id="structured-page-side-nav" class="nav flex-column structured-page-side-nav">
{% for block in page.body %}
<li role="presentation"><a href="#section{{ forloop.counter }}" class="structured-page-side-nav-link"><i class="fa fa-angle-right" aria-hidden="true"></i> {{ block.value.title }}</a></li>
{% endfor %}
</ul>
</div>
<div class="col-md-7 structured-page-sections-container" data-spy="scroll" data-target="#structured-page-side-nav" data-offset="70">
{% for block in page.body %}
<li role="presentation"><a href="#section{{ forloop.counter }}" class="structured-page-side-nav-link"><i class="fa fa-angle-right" aria-hidden="true"></i> {{ block.value.title }}</a></li>
{% endfor %}
</ul>
</div>
<div class="col-md-7 structured-page-sections-container" data-spy="scroll" data-target="#structured-page-side-nav" data-offset="70">
{% for block in page.body %}
{% if block.block_types == richtext_columns %}
<span class="structured-page-section__anchor" id="section{{ forloop.counter }}"></span>
<h2>{{ block.value.title }}</h2>
<div class="clearfix">
{% include_block block.value.content %}
</div>
{% else %}
<span class="structured-page-section__anchor" id="section{{ forloop.counter }}"></span>
<div class="structured-page-section">
<h2>{{ block.value.title }}</h2>
<div class="clearfix">
{% for block_content in block.value.content %}
{% include_block block_content %}
{% endfor %}
</div>
<div class="structured-page-section clearfix">
{% include_block block %}
</div>
{% endif %}
{% endfor %}
</div>
{% endfor %}
</div>
</div>
</div>
{% endblock %}

0 comments on commit a69db99

Please sign in to comment.