[FIX] website: condition to flag a menu as `active` in the top menu

1. A menu with `/page/website.***` should be flagged as `active`
if the current url is `/page/***`. This is a retro-compatibility
patch for c9d41679fb, so the
menu is marked as active without having to rename it, by
removing this `website.` thing.

2. If you defined two menus with as url `/page/test` and `/page/test2`
Both menus were flagged as `active` when you browsed the url
`/page/test2`, because it started by both menus urls.

Fixes #3059
Closes #3070
This commit is contained in:
Denis Ledoux 2015-08-14 17:02:53 +02:00
parent c9d41679fb
commit 19b5ba2b08
1 changed files with 3 additions and 4 deletions

View File

@ -33,16 +33,15 @@
<template id="website.submenu" name="Submenu">
<li t-if="not submenu.child_id" t-att-class="
((submenu.url and submenu.url != '/' and request.httprequest.path.startswith(submenu.url)) or
request.httprequest.path == submenu.url) and 'active'
'active' if submenu.url and submenu.url != '/' and request.httprequest.path == submenu.url.replace('/page/website.', '/page/') else None
">
<a t-att-href="(website.menu_id.child_id[0] == submenu) and '/' or submenu.url" t-ignore="true" t-att-target="'_blank' if submenu.new_window else None">
<span t-field="submenu.name"/>
</a>
</li>
<li t-if="submenu.child_id" t-attf-class="dropdown #{
((submenu.url and submenu.url != '/' and [1 for submenu in submenu.child_id if request.httprequest.path.startswith(submenu.url)]) or
request.httprequest.path == submenu.url) and 'active'
(submenu.url and submenu.url != '/' and any([request.httprequest.path == child.url.replace('/page/website.', '/page/') for child in submenu.child_id]) or
request.httprequest.path == submenu.url.replace('/page/website.', '/page/')) and 'active'
}">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
<span t-field="submenu.name"/> <span class="caret" t-ignore="true"></span>