diff --git a/cpm_generic/templates/cpm_generic/tags/mainmenu.html b/cpm_generic/templates/cpm_generic/tags/mainmenu.html index e8789e6..017995d 100644 --- a/cpm_generic/templates/cpm_generic/tags/mainmenu.html +++ b/cpm_generic/templates/cpm_generic/tags/mainmenu.html @@ -8,8 +8,15 @@ {% endfor %}
diff --git a/cpm_generic/templatetags/cpm_generic_tags.py b/cpm_generic/templatetags/cpm_generic_tags.py index 9d498d3..af1a7e0 100644 --- a/cpm_generic/templatetags/cpm_generic_tags.py +++ b/cpm_generic/templatetags/cpm_generic_tags.py @@ -1,27 +1,39 @@ -import re from django import template from django.utils import translation from django.conf import settings +from home.models import HomePage + register = template.Library() -@register.inclusion_tag('cpm_generic/tags/mainmenu.html') -def mainmenu(request): +def get_menu_pages(full_path): + homepage = HomePage.objects.get(slug='home') + children = list(homepage.get_children().live().in_menu().specific()) + return [(page, page.url == full_path) for page in [homepage] + children] + + +def get_language_paths(full_path): curr_lang = translation.get_language().split('-')[0] - full_path = request.get_full_path() - match = re.match(r'^/%s(?P