Project

General

Profile

Actions

Bug #21493

closed

JSMENU's showActive is broken

Added by Jörg Wagner over 14 years ago. Updated almost 14 years ago.

Status:
Closed
Priority:
Should have
Assignee:
Category:
Communication
Target version:
Start date:
2009-11-08
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
4.2
PHP Version:
5.2
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

The implementation of the JSMENUITEM property "showActive" is (very) flawed. It only works for a small subset of all possible HMENU configurations:
- Most HMENU.special variants (directory, list, browse,...) will stopp showActive from working.
- Any HMENU properties that change the menu to something other than a tree starting at the root page of the website (e.g. HMENU.entryLevel) will also break the function of showActive.
- Mountpoints in the root line will stopp showActive from working.

The problem is very simple to solve. The JSMENU code to determine if a page is active is found in /typo3/sysext/cms/tslib/class.tslib_menu.php:
$active = ($levelConf['showActive'] && $data['uid'] == $this->tmpl->rootLine[$count]['uid']);
This is very simplistic and will not work in any more complex cases (as listed above). The funny thing is that the same php file contains the method tslib_menu::isActive(), which does exactly (and does right) what JSMENU tries to do with the flawed approach above.
So simply replacing that line by...
$active = ($levelConf['showActive'] && $this->isActive($data['uid'], $MP_var));
...does the job.

Patches for 4.2.10 and 4.3.0beta2 are attached.
(issue imported from #M12505)


Files

Actions #1

Updated by Jörg Wagner over 14 years ago

If the patches are committed to core, the following bug reports can be closed too (they describe a subset of this problem and the attached patch solves them):
http://bugs.typo3.org/view.php?id=2571
http://bugs.typo3.org/view.php?id=5357

Actions #2

Updated by Jörg Wagner over 14 years ago

@Andreas Otto †:
You describe a totally different problem. Please set up another bug report for your issue.
Besides: How do you create a "content element of type menu/sitemap as jsmenu"?!? (Please explain in your new bug report - not here.)

Actions #3

Updated by Jörg Wagner over 14 years ago

To reproduce the original problem and its cure take these steps:

- In a virgin TYPO3...

- build a page tree like this:
P1
P2
P3
P4
P5
P6
P7

- use the TS setup below
(I assume that each page has a uid corresponding to its page number, otherwise you will have to modify the uids in page.35.special.value and page.45.special.value)

This will render four JSMENUs and a conventional text menu (for comparison). Use the conventional menu to navigate to all pages and see whether the dropdowns of each JSMENU will default to the current page and its rootline (if those are contained in that JSMENU).

The only JSMENU where this will always work correctly without the patch is the first one (because it starts at the root page, which is the only case in which the old isactive algorithm is correct). The other 3 JSMENUS will NEVER default to anything (the dropdowns will always default to the empty entry).

With the patch, all JSMENUs will correctly default to the currently active page and its parents if possible.

Cheers,
Jörg

#---------- TS-SETUP START -------------------

page = PAGE
page.typeNum = 0

page.10 = TEXT
page.10.value = <br><b>JSMENU normal:</b><br>
page.15 = HMENU
page.15{
1 = JSMENU
1 {
menuName = menu1
levels = 3
1.showActive = true
2.showActive = true
3.showActive = true
}
}

page.20 = TEXT
page.20.value = <br><b>JSMENU using entryLevel=1:</b><br>
page.25 = HMENU
page.25{
entryLevel=1
1 = JSMENU
1 {
menuName = menu2
levels = 3
1.showActive = true
2.showActive = true
3.showActive = true
}
}

page.30 = TEXT
page.30.value = <br><b>JSMENU in HMENU special=directory:</b><br>
page.35 = HMENU
page.35{
special=directory
special.value=2
1 = JSMENU
1 {
menuName = menu3
levels = 3
1.showActive = true
2.showActive = true
3.showActive = true
}
}

page.40 = TEXT
page.40.value = <br><b>JSMENU in HMENU special=list:</b><br>
page.45 = HMENU
page.45{
special=list
special.value=3,4
1 = JSMENU
1 {
menuName = menu4
levels = 3
1.showActive = true
2.showActive = true
3.showActive = true
}
}

page.90 = TEXT
page.90.value = <br><b>HMENU full menu (to compare against):</b><br>

page.95 = HMENU
page.95{
1=TMENU
1 {
expAll=1
NO=1
NO{
allWrap=|<br>
}
ACT<.NO
ACT{
stdWrap.wrap = <span style="font-weight: bold; color:#c00;">|</span>
}
}
2<.1
2.NO.allWrap=-- |<br>
2.ACT.allWrap=-- |<br>
3<.1
3.NO.allWrap=---- |<br>
3.ACT.allWrap=---- |<br>
4<.1
4.NO.allWrap=------ |<br>
4.ACT.allWrap=------ |<br>
5<.1
5.NO.allWrap=-------- |<br>
5.ACT.allWrap=-------- |<br>
}

#---------- TS-SETUP END -------------------

Actions

Also available in: Atom PDF