diff --git a/django_activeurl/conf.py b/django_activeurl/conf.py index d5b8b68..d81925e 100644 --- a/django_activeurl/conf.py +++ b/django_activeurl/conf.py @@ -21,5 +21,8 @@ class ActiveUrlConf(AppConf): 'menu': 'yes' } + # check url without GET parameters + WITHOUT_GET_PARAMS = True + class Meta: prefix = 'active_url' diff --git a/django_activeurl/utils.py b/django_activeurl/utils.py index c65f205..89894b9 100644 --- a/django_activeurl/utils.py +++ b/django_activeurl/utils.py @@ -54,6 +54,11 @@ def get_cache_key(content, css_class, parent_tag, full_path, menu): def check_active(url, element, full_path, css_class, menu): '''check "active" url, apply css_class''' + + if settings.ACTIVE_URL_WITHOUT_GET_PARAMS: + # cut off GET params + full_path = re.sub(r'\?.+', '', full_path) + # django > 1.5 template boolean\None variables feature if isinstance(menu, bool): if menu: @@ -77,6 +82,9 @@ def check_active(url, element, full_path, css_class, menu): href = url.attrib['href'].strip() # cut off hashtag (anchor) href = re.sub(r'\#.+', '', href) + if settings.ACTIVE_URL_WITHOUT_GET_PARAMS: + # cut off GET params + href = re.sub(r'\?.+', '', href) # check empty href if href == '': # replace href with current location