问题
I'm trying to create a menu that displays in TYPO3 all subpages and the parent page. My problem is that I find no way to assign entryLevel
dynamically.
I'm working with TYPO3 6.1
This is currently my typoscript for the menu.
lib.mainnavi = HMENU
lib.mainnavi {
entryLevel = 1
1 = TMENU
1.wrap = <ul> | </ul>
1 {
noBlur = 1
NO {
subst_elementUid = 1
allWrap = <li id="link{elementUid}" class="first">| |*| <li id="link{elementUid}">| |*| <li id="link{elementUid}" class="last">|
wrapItemAndSub = |</li>
}
ACT = 1
ACT {
subst_elementUid = 1
allWrap = <li id="link{elementUid}" class="first current first_current">| |*| <li id="link{elementUid}" class="current">| |*| <li id="link{elementUid}" class="last current last_current">|
wrapItemAndSub = |</li>
}
}
}
Below is a picture to illustrate what I want.
When I go to "1", I want to see "FAQ", "GTC (EU)" and "GTC (USA)".
When I go to "FAQ", I want to see A-J and "1" as "back".
When I go to "A", I want to see "FAQ" as "back"

I can make the "back" menu with a seccond menu and special = browse
. But I can't find a way to set entryLevel
dynamically
回答1:
Entry level can get positive and negative values.
While the positive values are marking absolute level positions counting from the root page.
Root => 0
- Page => 1
- Page => 2
- Current Page => 3
negative values will be relative and counted from the current page back to the root
Root => -4
- Page => -3
-Page => -2
- Current Page => -1
This way you don't have to use conditions for every level, which would just bloat your caching tables.
Root => 0
- Page => 1
- Current Page => 2
Root => -3
- Page => -2
- Current Page => -1
回答2:
You can adjust the entryLevel
setting with a condition below your TS code. Just have a look at the documentation for the treeLevel
condition.
Use it like this:
[treeLevel = 2]
lib.mainnavi.entryLevel = 2
[end]
回答3:
There is a nother solution, that does not use entryLevel at all:
lib.mainnavi = HMENU
lib.mainnavi {
special = directory
special.value.field = uid
...
}
This would create a menu of pages having the UID of the current page as PID, AKA subpages of the current page.
回答4:
This did the trick for me:
lib.mainnavi = HMENU
lib.mainnavi {
entryLevel = 1
special = directory
special.value.data = leveluid:-1
# your code here ...
}
来源:https://stackoverflow.com/questions/17919874/typo3-menu-how-to-set-entrylevel-dynamic