Skip to content

Commit

Permalink
Template code updated to make sure to only display live wagtail pages
Browse files Browse the repository at this point in the history
  • Loading branch information
sanjeevz3009 committed Jan 15, 2025
1 parent 6256698 commit e47db05
Showing 1 changed file with 31 additions and 14 deletions.
45 changes: 31 additions & 14 deletions cms/jinja2/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

{% if navigation_settings.main_menu and navigation_settings.main_menu.highlights %}
{% for highlight in navigation_settings.main_menu.highlights %}
{% if highlight.value.page %}
{% if highlight.value.page and highlight.value.page.live %}
{% set _ = keyLinksList.append({
'text': highlight.value.title if highlight.value.title else highlight.value.page.title,
'description': highlight.value.description,
Expand All @@ -67,23 +67,40 @@
} %}

{% for section in column.value.sections %}
{% set sectionData = {
'text': section.section_link.title or (section.section_link.page and section.section_link.page.title),
'url': section.section_link.external_url or (section.section_link.page and pageurl(section.section_link.page)),
'children': []
} %}
{% if section.section_link.page and section.section_link.page.live %}
{% set sectionData = {
'text': section.section_link.title or section.section_link.page.title,
'url': pageurl(section.section_link.page),
'children': []
} %}
{% elif section.section_link.external_url %}
{% set sectionData = {
'text': section.section_link.title,
'url': section.section_link.external_url,
'children': []
} %}
{% endif %}

{% for link in section.links %}
{% set _ = sectionData.children.append({
'text': link.title or (link.page and link.page.title),
'url': link.external_url or (link.page and pageurl(link.page)),
}) %}
{% endfor %}
{% if sectionData %}
{% for link in section.links %}
{% if link.page and link.page.live%}
{% do sectionData.children.append({
'text': link.title or link.page.title,
'url': pageurl(link.page),
}) %}
{% elif link.external_url %}
{% do sectionData.children.append({
'text': link.title,
'url': link.external_url,
}) %}
{% endif %}
{% endfor %}
{% endif %}

{% set _ = columnData.linksList.append(sectionData) %}
{% do columnData.linksList.append(sectionData) %}
{% endfor %}

{% set _ = itemsList.append(columnData) %}
{% do itemsList.append(columnData) %}
{% endfor %}
{% endif %}

Expand Down

0 comments on commit e47db05

Please sign in to comment.