Skip to content

Commit

Permalink
* Move /about into primary nav
Browse files Browse the repository at this point in the history
* Add parameter and condition to bg_active_nav if primary nav or sidebar nav
* Set target active state based on if current link is part of the path
  • Loading branch information
robdivincenzo committed Mar 14, 2024
1 parent 45ca601 commit 6567bdc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{% load bg_nav_tags i18n wagtailroutablepage_tags %}

{% with request.get_full_path as current_url %}
{% routablepageurl page 'about-why-view' as about_why_url %}
{% routablepageurl page 'how-to-use-view' as how_to_use_url %}
{% routablepageurl page 'about-why-view' as about_why_url %}
{% routablepageurl page 'methodology-view' as methodology_url %}
{% routablepageurl page 'contact-view' as contact_url %}
{% routablepageurl page 'press-view' as press_url %}

<div class="col-lg-3">
<nav class="vertical-nav mt-5 pt-sm-2" title="{% trans "about sections" context "Tooltip on menu items" %}">
<div class="multipage-link-wrapper"><a class="multipage-link about-link {% bg_active_nav current_url about_why_url %}" href="{{ about_why_url }}">{% trans "Why we made this guide" %}</a></div>
<div class="multipage-link-wrapper"><a class="multipage-link about-link {% bg_active_nav current_url how_to_use_url %}" href="{{ how_to_use_url }}">{% trans "How to use this guide" %}</a></div>
<div class="multipage-link-wrapper"><a class="multipage-link about-link {% bg_active_nav current_url about_why_url %}" href="{{ about_why_url }}">{% trans "Why we made this guide" %}</a></div>
<div class="multipage-link-wrapper"><a class="multipage-link about-link {% bg_active_nav current_url methodology_url %}" href="{{ methodology_url }}">{% trans "Methodology" %}</a></div>
<div class="multipage-link-wrapper"><a class="multipage-link about-link {% bg_active_nav current_url contact_url %}" href="{{ contact_url }}">{% trans "Contact us" %}</a></div>
<div class="multipage-link-wrapper"><a class="multipage-link about-link {% bg_active_nav current_url press_url %}" href="{{ press_url }}">{% trans "Press" %}</a></div>
</nav>
</div>

{% endwith %}
{% endwith %}
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
height="10"
>
{% if editorial_content_index %}
<a class="{{ class }} {% bg_active_nav request.get_full_path editorial_content_index.url %} " href="{% pageurl editorial_content_index %}">{{ editorial_content_index }}</a>
<a class="{{ class }} {% bg_active_nav request.get_full_path editorial_content_index.url 'primary_nav' %} " href="{% pageurl editorial_content_index %}">{{ editorial_content_index }}</a>
{% endif %}
{% endwith %}
{% routablepageurl home_page 'about-why-view' as about_why_url %}
<a class="{{ class }} {% bg_active_nav request.get_full_path about_why_url %}" href="{{ about_why_url }}">{% trans "About" %}</a>
{% routablepageurl home_page 'how-to-use-view' as how_to_use_url %}

<a class="{{ class }} {% bg_active_nav request.get_full_path how_to_use_url 'primary_nav' %}" href="{{ how_to_use_url }}">{% trans "About" %}</a>
<a data-donate-header-button class="{{ class }}" href="?form=donate&utm_medium=FMO&utm_source=PNI&utm_campaign=23-PNI&utm_content=header&c_id=7014x000000eQOD">{% trans "Donate" %}</a>
{{ post }}
10 changes: 6 additions & 4 deletions network-api/networkapi/wagtailpages/templatetags/bg_nav_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@ def check_active_category(current_category, target_category):
return "active" if match else ""


# Determine if a nav link should be active.
# Determine if a nav (sidebar nav or primary nav) link should be active.
@register.simple_tag(name="bg_active_nav")
def bg_active_nav(current, target):
return "active" if urlparse(target).path in urlparse(current).path else ""

def bg_active_nav(current, target, nav="sidebar"):
if nav == "primary_nav":
return "active" if urlparse(target).path in urlparse(current).path else ""
else:
return "active" if urlparse(target).path == urlparse(current).path else ""

@register.simple_tag(name="product_in_category")
def product_in_category(productpage, categorySlug):
Expand Down

0 comments on commit 6567bdc

Please sign in to comment.