Header menu
This commit is contained in:
parent
2a2eca14f3
commit
0f27d97d64
8 changed files with 69 additions and 37 deletions
|
@ -1,5 +1,4 @@
|
|||
{% load wagtailcore_tags %}
|
||||
{% load wagtailimages_tags %}
|
||||
{% load wagtailcore_tags wagtailimages_tags %}
|
||||
|
||||
<div id="carousel-banner" class="slide">
|
||||
<div class="carousel-inner slick" role="listbox">
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
{% extends "base.html" %}
|
||||
{% load wagtailcore_tags %}
|
||||
{% load wagtailimages_tags %}
|
||||
{% load wagtailcore_tags wagtailimages_tags %}
|
||||
|
||||
{% block body_class %}template-{{ self.get_verbose_name|slugify }}{% endblock %}
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
{% extends "base.html" %}
|
||||
{% load wagtailcore_tags %}
|
||||
{% load wagtailimages_tags %}
|
||||
{% load wagtailcore_tags wagtailimages_tags %}
|
||||
|
||||
{% block body_class %}template-{{ self.get_verbose_name|slugify }}{% endblock %}
|
||||
|
||||
|
|
18
publichealth/home/templates/tags/top_menu.html
Normal file
18
publichealth/home/templates/tags/top_menu.html
Normal file
|
@ -0,0 +1,18 @@
|
|||
{% load navigation wagtailcore_tags %}
|
||||
{% get_site_root as site_root %}
|
||||
|
||||
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
{% for menuitem in menuitems %}
|
||||
<li class="{% if menuitem.show_dropdown %}dropdown{% endif %}{% if menuitem.active %} active{% endif %}">
|
||||
{% if menuitem.show_dropdown %}
|
||||
<a data-toggle="dropdown" class="dropdown-toggle" href="#">{{ menuitem.title }} <b class="caret"></b></a>
|
||||
{% top_menu_children parent=menuitem %}
|
||||
{% else %}
|
||||
<a href="{% pageurl menuitem %}">{{ menuitem.title }}</a>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
<!-- /.navbar-collapse -->
|
8
publichealth/home/templates/tags/top_menu_children.html
Normal file
8
publichealth/home/templates/tags/top_menu_children.html
Normal file
|
@ -0,0 +1,8 @@
|
|||
{% load navigation wagtailcore_tags %}
|
||||
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="{% pageurl parent %}">{{ parent.title }}</a></li>
|
||||
{% for child in menuitems_children %}
|
||||
<li><a href="{% pageurl child %}">{{ child.title }}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
|
@ -12,3 +12,37 @@ def language_switcher(context):
|
|||
'currentlangcode': translation.get_language(),
|
||||
'request': context['request'],
|
||||
}
|
||||
|
||||
@register.assignment_tag(takes_context=True)
|
||||
def get_site_root(context):
|
||||
# NB this returns a core.Page, not the implementation-specific model used
|
||||
# so object-comparison to self will return false as objects would differ
|
||||
return context['request'].site.root_page
|
||||
|
||||
def has_menu_children(page):
|
||||
return page.get_children().live().in_menu().exists()
|
||||
|
||||
# Retrieves the top menu items
|
||||
@register.inclusion_tag('tags/top_menu.html', takes_context=True)
|
||||
def top_menu(context, parent, calling_page=None):
|
||||
menuitems = parent.get_children().live().in_menu()
|
||||
for menuitem in menuitems:
|
||||
menuitem.show_dropdown = has_menu_children(menuitem)
|
||||
menuitem.active = (calling_page.url.startswith(menuitem.url)
|
||||
if calling_page else False)
|
||||
return {
|
||||
'calling_page': calling_page,
|
||||
'menuitems': menuitems,
|
||||
'request': context['request'],
|
||||
}
|
||||
|
||||
# Retrieves the children of the top menu items for the drop downs
|
||||
@register.inclusion_tag('tags/top_menu_children.html', takes_context=True)
|
||||
def top_menu_children(context, parent):
|
||||
menuitems_children = parent.get_children()
|
||||
menuitems_children = menuitems_children.live().in_menu()
|
||||
return {
|
||||
'parent': parent,
|
||||
'menuitems_children': menuitems_children,
|
||||
'request': context['request'],
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
<li><a href="#">Information zu Public Health</a></li>
|
||||
<li><a href="#">Agenda</a></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
<div class="col-md-4" id="contact">
|
||||
<address>
|
||||
|
@ -39,7 +38,6 @@
|
|||
</div>
|
||||
<button class="btn btn-priamry" type="submit">Senden</button>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
</div><!-- /row -->
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{% load wagtailcore_tags navigation %}
|
||||
{% get_site_root as site_root %}
|
||||
|
||||
<nav class="navbar-pre navbar-fixed-top">
|
||||
<div class="container">
|
||||
|
@ -28,38 +29,14 @@
|
|||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="/de/home"><img src="/static/images/public-health-logo-sign.png" alt="[logo]">
|
||||
<a class="navbar-brand" href="{% pageurl site_root %}"><img src="/static/images/public-health-logo-sign.png" alt="[logo]">
|
||||
<span class="hidden-xs"><strong>Public Health</strong> Schweiz</span></a>
|
||||
</div>
|
||||
|
||||
<!-- Collect the nav links, forms, and other content for toggling -->
|
||||
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Über uns <span class="caret"></span></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="#">Mitglied werden</a></li>
|
||||
<li><a href="#">Informationen zu Public Health</a></li>
|
||||
<li><a href="#">Stellenangebote</a></li>
|
||||
<li role="separator" class="divider"></li>
|
||||
<li><a href="#">Migliederversammlung</a></li>
|
||||
<li><a href="#">Fachrat</a></li>
|
||||
<li><a href="#">Vorstand</a></li>
|
||||
<li><a href="#">Fachgruppen</a></li>
|
||||
<li><a href="#">Geschäftsstelle</a></li>
|
||||
<li><a href="#">Grundlagedokumente</a></li>
|
||||
<li><a href="#">Jahresberichte</a></li>
|
||||
<li><a href="#">Archiv</a></li>
|
||||
<li role="separator" class="divider"></li>
|
||||
<li><a href="#">Kontakt</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#">News</a></li>
|
||||
<li><a href="#">Agenda</a></li>
|
||||
<li><a href="#">Projekte</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<!-- /.navbar-collapse -->
|
||||
{% block menu %}
|
||||
<!-- Top Menu -->
|
||||
{% top_menu parent=site_root calling_page=self %}
|
||||
{% endblock %}
|
||||
</div>
|
||||
<!-- /.container -->
|
||||
</nav>
|
||||
|
|
Loading…
Reference in a new issue