TYPO3 menu: how to set "entryLevel" dynamic? - typo3

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

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

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]

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.

This did the trick for me:
lib.mainnavi = HMENU
lib.mainnavi {
entryLevel = 1
special = directory
special.value.data = leveluid:-1
# your code here ...
}

Related

TYPO3 doesn't show any pages in submenu

In my TYPO3 I have this code for submenu
lib.subnav = COA
lib.subnav {
wrap = <ul class="nav nav-list" id="sidebar-nav">|</ul>
10 = TEXT
10.wrap = <li class="list-group-item">|</li>
#10.wrap {
# override = <li class="list-group-item current">|</li>
# override.if {
# value.data = field:uid
# equals.data = leveluid:1
# }
#}
10.data = leveltitle:1
#10.data = levelfield:1,nav_title // leveltitle:1
10.typolink.parameter.data = leveluid:1
20 = HMENU
20.wrap = |
20 {
entryLevel = 1
1 = TMENU
1 {
wrap = |
expAll = 0
NO = 1
NO.allWrap >
NO.wrapItemAndSub = <li class="list-group-item">|</li>
CUR = 1
CUR < .NO
CUR.wrapItemAndSub = <li class="list-group-item active current">|</li>
ACT = 1
ACT < .CUR
ACT.wrapItemAndSub = <li class="list-group-item active">|</li>
# Dropdown menu
IFSUB = 1
IFSUB < .NO
IFSUB.wrapItemAndSub = <li class="list-group-item">|</li>
IFSUB.ATagBeforeWrap = 1
IFSUB.stdWrap.wrap = |
CURIFSUB = 1
CURIFSUB < .IFSUB
CURIFSUB.wrapItemAndSub = <li class="list-group-item active current">|</li>
ACTIFSUB = 1
ACTIFSUB < .IFSUB
ACTIFSUB.wrapItemAndSub = <li class="list-group-item active">|</li>
}
2 = TMENU
2 {
wrap = <ul class="list-group">|</ul>
expAll = 0
NO = 1
NO.allWrap >
NO.wrapItemAndSub = <li class="list-group-item">|</li>
ACT = 1
ACT < .NO
ACT.wrapItemAndSub = <li class="list-group-item active">|</li>
CUR = 1
CUR < .ACT
CUR.wrapItemAndSub = <li class="list-group-item active current">|</li>
IFUSB < .1.IFSUB
ACTIFSUB < .1.ACTIFSUB
CURIFSUB < .1.CURIFSUB
SPC = 1
SPC.doNotLinkIt = 1
SPC.doNotShowLink = 1
SPC.allWrap = <li class="divider"></li>
}
3 < .2
# no submenus anymore
3.IFSUB >
3.ACTIFSUB >
}
}
If I wiev the source of the page I can se this line: | but no menu items.
I have tried to chage submenu.entrylevel, but nothing changes.
There a subpages, so that is not the problem.
It is TYPO3 8.7 and I know that it is terrible old, but I need this to work before an update.
Let's have an example page:
Home/Root
Page 1
Page 1.1
Page 1.1.1
Page 1.2
Page 2
Page 3
Page 3.1
Page 3.2
Page 3.2.1
Regarding entryLevel:
Default is "0" which gives us a menu of the very first pages on the site. For the tree above, the menu will contain "Page 1", "Page 2", "Page 3".
entryLevel=1 will show the pages below. So, if you are on "Page 1", the menu will show "Page 1.1." and "Page 1.2" (active rootline). On "Page 2" the menu will not show up anything, because there are no pages below Page 2. On "Home/Root" no menu will appear because there's no level 1 directly underneath.
expAll
If this is true, the menu will always show the menu on the level underneath the menu item.
Back to the pagetree: having entryLevel=0 and 20.1.expAll=1 all submenus of the third level will be expanded, not only the one of active rootline. All "Page x.x" will appear, but none of the "Page x.x.x".
For getting a full dropdown-menu, also the next level needs to be expanded: 20.2.expAll=1

How to split menu in parts with typoscript

I have a Typoscript menu with a lot of items and want to split it into several blocks of 6 items each.
My typoscript looks like this at the moment:
lib.mainnav = HMENU
lib.mainnav {
1 = TMENU
1 {
wrap = <ul>|</ul>
expAll = 1
NO = 1
NO.wrapItemAndSub = <li>|</li>
NO.stdWrap.htmlSpecialChars = 1
NO.ATagParams = name = "{field:title}"
NO.allStdWrap.insertData = 1
}
[ ... ]
}
After every 6th item a </ul><ul> should be inserted here. I have already tried a lot of things, but have not yet reached the desired result.
Does anyone have a tip for me?
Thanks in advance for your help!
NO.wrapItemAndSub = <li>|</li> || <li>|</li> || <li>|</li> || <li>|</li> || <li>|</li> || <li>|</li></ul><ul> |*| |*|
Keep in mind that you will have an empty <ul></ul> if you have a multiple of 6 entries in your menu.

TYPO3: typoscript wrap two elements with div

is it possible to wrap always two <li> elements in a div in typoscript?
at the moment it looks like this:
navStatic = HMENU
navStatic {
special = directory
special.value = 2
excludeUidList = 2
1 = TMENU
1 {
expAll = 1
wrap = <ul class="headernavmenu">|</ul>
noBlur = 1
NO = 1
NO {
ATagTitle.field = title
wrapItemAndSub = <li>|</li>
allWrap = | I |*| | I |*| |
}
ACT < .NO
ACT.ATagParams = class="active_static"
}
}
thanks in advance
This addition to your TypoScript should do the job, just when an odd number of li-elements is in the list the last single li-element is not wrapped.
NO.wrapItemAndSub.outerWrap = <div class="two-list-elements"> || || </div>
Be advised that this HTML-solution is error-prone as browsers might interpret it different or not at all because the HTML is not standard-conform.

Typo3: Output of all 2nd level pages as menu independent of active pages

I want to create a menu of all 2nd level items at once in separate DIVs (outside the first level menu) - independent of the active page. Do you have an hint for me? Thank you very much for your help!!
don't forget to configure
1.expAll = 1
in your typoscript menu definition
I think you are looking something like this:
lib.menu = COA
lib.menu {
# Menu of first Level
10 = HMENU
10.entryLevel = 0
10.1 = TMENU
10.1.wrap = <ul> | </ul>
10.1.NO.allWrap = <li>|</li>
# Menu of all second levels
20 = HMENU
20.entryLevel = 0
20.1 = TMENU
20.1.expAll = 1
20.1.NO.doNotLinkIt = 1
20.1.NO.doNotShowLink =1
20.1.IFSUB = 1
20.1.IFSUB.doNotLinkIt = 1
20.1.IFSUB.allWrap = <h4>2°lv (|) </h4>
20.2 = TMENU
20.2.wrap = <ul> | </ul>
20.2.NO.allWrap = <li> | </li>
}
Thank you for your answers! I found a similar solution like the one Cristian Buja posted, that works fine for me. Here's the code if someone have the same issue: `lib.subnav = HMENU
lib.subnav {
1 = TMENU
1 {
expAll = 1
NO.doNotShowLink = 1
IFSUB = 1
IFSUB.doNotShowLink = 1
IFSUB.allWrap = <div id="s{elementUid}" class="nv-sub-wrapper"><div class="nv-sub-menu clearfix">|
IFSUB.wrapItemAndSub = |<div class="nv-sub-info"></div></div></div>
IFSUB.subst_elementUid = 1
}
2 = TMENU
2 {
wrap = <ul>|</ul>
NO = 0
NO {
ATagParams = data-description="{field:abstract // field:subtitle // field:title}"
ATagParams.insertData = 1
wrapItemAndSub = <li>|</li>
}
}
}`

Typoscript navigation setup

I am new to typo3 and I have to setup a navigation. I have already done the tutorials found at Timerate and I have built the demo navigation (week 2 in the tutorial).
Now I have to setup a navigation that must look like :
Link 1 | Link 2 | Link 3 | Link 4
the back en structure is the following :
Link 1
Link 2
Link 3 (shortcut to sub link 1)
Sublink 1
Sublink 2
Link 4
The whole menu is working fine when I am in section designated by link 1, link 2 and link 4 but there is nothing showing when I click on link 3.
The Sublinks are to be shown in a secondary navigation
Here is the typoscript that I have on my root ts template (I'm using TemplaVoila) :
lib.field_topmenu = HMENU
lib.field_topmenu {
special = directory
special.value = {$idMain}
entryLevel = 2
1 = TMENU
1.NO = 1
1.wrap = <div id="menu"><ul> | </ul></div>
1.NO.wrapItemAndSub = <li>|</li>
1.ACT < .1.NO
1.ACT.ATagParams = class='active'
2 < .1
}
What would be the best way to achieve this?
glad you're on board of TYPO3.
As far as I can remember, there's no effect on the entry level of a special = directory.
That's a working solution:
lib.field_topmenu = HMENU
lib.field_topmenu {
special = directory
special.value = 1
1 = TMENU
1.NO = 1
1.wrap = <ul> | </ul>
1.NO.wrapItemAndSub = <li>|</li>
1.ACT < .NO
1.ACT.ATagParams = class='active'
2 < .1
}
You should remove the id=menu as it will be repeated the levels downwards, therefore invalidating your HTML
Here's a solution we usually use, it also uses subtitles etc. and adds special classes to the first and last elements of your navigation list:
lib.navi.one = HMENU
lib.navi.one {
1 = TMENU
1 {
noBlur = 1
wrap = <ul>|</ul>
NO = 1
NO {
wrapItemAndSub = <li class="first">|</li> |*| <li>|</li> |*| <li class="last">|</li>
altText = subtitle // title
title = subtitle // title
}
CUR < .NO
CUR.wrapItemAndSub = <li class="active first">|</li> |*| <li class="active">|</li> |*| <li class="active last">|</li>
ACT < .CUR
}
2 < .1
3 < .2
4 < .2
}
you can quite easily adopt it to your directory starting point (and take away levels 3 & 4):
lib.field_topmenu < lib.navi.one
lib.field_topmenu {
special = directory
special.value = {$idMain}
3 >
4 >
}
aTagParams doesn´t work with shortcuts. you have to put the real pages into the sys folder than it will work.