Add 'active' tag to show active page in navs.

This commit is contained in:
Casper V. Kristensen 2020-01-11 23:02:20 +01:00
parent 57d5b3f131
commit 620796448d
Signed by: caspervk
GPG key ID: 289CA03790535054
3 changed files with 14 additions and 2 deletions

View file

@ -1,4 +1,5 @@
{% load static %}
{% load base_extras %}
<!DOCTYPE html>
<html class="h-100" lang="en">
@ -22,8 +23,9 @@
<div class="collapse navbar-collapse" id="navbar-collapse">
<div class="navbar-nav mr-auto">
<a class="nav-item nav-link" href="{% url 'raid_calendar' %}">Raids</a>
<a class="nav-item nav-link" href="{% url 'attendance' %}">Attendance</a>
<a class="nav-item nav-link {% active 'raid_calendar' %}" href="{% url 'raid_calendar' %}">Raids</a>
<a class="nav-item nav-link {% active 'attendance' %}" href="{% url 'attendance' %}">Attendance</a>
<a class="nav-item nav-link {% active 'bank' %}" href="{% url 'bank' %}">Bank</a>
<!--<a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">DKP</a>-->
</div>
{% if user.is_authenticated %}

View file

View file

@ -0,0 +1,10 @@
from django import template
register = template.Library()
@register.simple_tag(takes_context=True)
def active(context, url_name):
if context["request"].resolver_match.url_name == url_name:
return "active"
return ""