TMENU - only mark current page as active, not parents - typo3

I have a menu currently looking like this. Not only the current active item is marked as active, but also its parents and all the way up. How can I make it so parents aren't marked?
Here's the menu typoscript.
lib.secondNavi = HMENU
lib.secondNavi.entryLevel=0
lib.secondNavi.1 = TMENU
lib.secondNavi.1 {
wrap = <ul id="secondNavi">|</ul>
expAll = 0
NO.allWrap = <li>|</li>
RO < .NO
RO = 1
CUR < .NO
CUR = 1
CUR.allWrap = <li class="active">|</li>
ACT < .CUR
}
lib.secondNavi.2 < lib.secondNavi.1
lib.secondNavi.2 {
wrap = <ul>|</ul>
}
lib.secondNavi.3 < lib.secondNavi.2
lib.secondNavi.3 {
wrap = <ul>|</ul>
}
Using Typo3 6.1.7.

Active (ACT) in TypoScript means current page AND each parent in the page tree.
Current page (CUR) is only the page that you are on (determined by its ID)
documentation
You are copying settings of CUR to ACT so you have mark the pages on rootline as well, just remove the ACT < .CUR line or on other levels empty it by: ACT >

Related

TYPO3CMS: Different Menu Language than Content

Our customer wants, why the hell not, a Spanish Homepage, but the menu should refer to the English pages.
Unfortunately English isn't the default language in the system.
Is this somehow possible to achieve within TYPO3?
The menu is generated via Typoscript:
lib.nav = HMENU
lib.nav {
wrap = <ul class="noListStyle">|</ul>
entryLevel = 0
1 = TMENU
1 {
noBlur = 1
expAll = 1
NO = 1
NO {
wrapItemAndSub = <li>|</li>
ATagParams = data-id="{field:uid}"
allStdWrap.insertData = 1
}
CUR < lib.nav.1.NO
CUR {
wrapItemAndSub = <li class="active">|</li>
}
ACT < lib.nav.1.NO
ACT {
wrapItemAndSub = <li class="active">|</li>
}
IFSUB < lib.nav.1.NO
IFSUB {
wrapItemAndSub = <li class="hasChildren">|</li>
# doNotLinkIt = 1
}
CURIFSUB = 1
CURIFSUB {
wrapItemAndSub = <li class="hasChildren active">|</li>
}
ACTIFSUB = 1
ACTIFSUB {
wrapItemAndSub = <li class="hasChildren active">|</li>
}
SPC = 1
SPC {
doNotLinkIt = 1
doNotShowLink = 1
allWrap = <li class="spacer">|</li>
}
}
2 < lib.nav.1
2 {
wrap = <ul class="navSub">|</ul>
}
}
The solution to fallback to another language than the default one is using config.sys_language_mode = content_fallback. As you can read in the Docs, with this mode you can specify some language UIDs to which language you want to fallback: https://docs.typo3.org/typo3cms/TyposcriptReference/Setup/Config/Index.html#sys-language-mode
However, the content on the page can still fall back to another
language, defined by the value of this keyword, e.g.
content_fallback;1,3,0, to fall back to the content of
sys_language_uid 1, after that to the content of sys_language_uid 3
and if that is not present either, to default (0).
In your case you still have to find a way, how to hide the spanish pages from the menue but having a fallback to english. Maybe there is something in the page language overlay configuration?
In the worst case you have get the page titles in the TMENU object "manually" by requesting the DB.
EDIT: And how about just naming the spanish pages titles with english titles by hand?

TypoScript Menu with manual columns

I have a typical grid-based dropdown menu with predefined columns, as you find them in foundation, bootstrap etc.
Now I'd like to manually let the editor control which items go in which column – without having to hardwire too many pids or creating additional pagetree nodes (Pages like "Group for column 1") in the BE.
How do I do that with TypoScript?
The page type "Spacer" or "Separator" (doktype 199) is perfect for this:
It can be rendered as html content, using the SPC state. Editors can place it in their pagetree where they want to split up columns.
lib.main_nav_1 = HMENU
lib.main_nav_1 {
special = directory
special.value = {$pidEntryPoint}
wrap = <div class="columns small-12 medium-3"><ul>|</ul></div>
1 = TMENU
1 {
expAll = 1
NO {
text = nav_title // title
wrapItemAndSub=<li>|</li>
}
ACT < .NO
ACT {
wrapItemAndSub = <li class="active">|</li>
}
ACT = 1
CUR < .NO
CUR {
wrapItemAndSub = <li class="current">|</li>
}
CUR = 1
SPC = 1
SPC {
doNotLinkIt = 1
doNotShowLink = 1
allWrap = </ul></div><div class="columns small-12 medium-3">|<ul>
}
}
2 < .1
2 {
wrap = <ul>|</ul>
SPC = 0
}
}
}

TYPO3 hmenu disable one link

I have menu with 2 level. All links are clickable but I want to disable 1 link. This link is being used for opening submenu
<li class="sub-link">link1
<ul id="sub-menu">
<li>sublink</li>
<li>sublink2</li>
</ul> <!-- sub-menu -->
</li>
<li>link2</li>
<li>link3</li>
<li>link4</li>
<li>link5</li>
I want to disable link 1. I have such typoscript:
lib.menu.main = HMENU
lib.menu.main {
special = list
special.value = 22,154,88
alwaysActivePIDlist = 22
1 = TMENU
1.NO = 1
1.wrap = <ul>|</ul>
1.NO.wrapItemAndSub = <li>|</li>
1.IFSUB=1
1.IFSUB.wrapItemAndSub = <li class="sub-link">|</li>
2 < .1
2.wrap = <ul id="sub-menu">|</ul>
2.NO.wrapItemAndSub = <li>|</li>
}
How I can decide this problem?
So i got two possibilities for you to solve this problem:
The first one is to read the Typo3-Documentation and look up for "optionSplit" and "doNotLinkIt"-options. They should help you solving your problem within typoscript.
The other is to solve it using Javascript/JQuery. You could select the (in your example above) FIRST item of the menu and replace the link with whatever you want.
$(document).ready(function(){
$('.menu a').first().attr('href', '#');
});
I made you a fiddle with the whole example:
https://jsfiddle.net/bdrsssv7/
Make sure you do not insert the Javascript in the HTML template because it will not be available on pages with other html-templates then.
Just do a js-file and insert it via typoscript like this:
page.includeJS.file1 = fileadmin/yourTemplateLocation/yourFile.js
I hope one of the two solutions i mentioned could help you
Excluding a specific PID (18) from the menu in Typoscript:
lib.menu = HMENU
lib.menu {
special = rootline
special.range = 2,0
1 = TMENU
1 {
NO {
allWrap = <li> | </li>
doNotLinkIt.override = 1
doNotLinkIt.override.if {
value = 18
equals.field = uid
}
}
}
}
OR exclude multiple specific PIDs (18,19,20) from the menu
lib.menu.1.NO.doNotLinkIt.override.if {
value = 18,19,20
isInList.field = uid
}

Id counting in TYPO3 menu using register:count_MENUOBJ

I made the menu in TYPO3 for bootstrap framework. Everything working just fine, but I have problem with counting the id element using register:count_MENUOBJ. The whole menu is constructed from two parts - main menu and sub menu:
page = PAGE
page.10 = HMENU
page.10.special = directory
page.10.entryLevel = 0
page.10.maxItems = 6
page.10 {
1 = TMENU
1 {
wrap = <div class="row"><ul class="nav nav-tabs pull-right" id="myTab" role="tablist">|</ul></div>
noBlur = 1
expAll = 1
NO {
ATagTitle.field = title
wrapItemAndSub = <li class="dropdown">|</li>
stdWrap.htmlSpecialChars = 1
accessKey = 1
}
IFSUB < .NO
IFSUB = 1
IFSUB {
wrapItemAndSub = <li class="dropdown">|</li>
linkWrap= |
ATagParams = role="button" data-toggle="collapse" data-target="#item-{register:count_MENUOBJ}"
ATagParams.insertData = 1
ATagBeforeWrap = 1
stdWrap.htmlSpecialChars = 1
}
ACTIFSUB < .IFSUB
ACTIFSUB {
wrapItemAndSub = <li class="active dropdown">|</li>
}
ACT < .NO
ACT = 1
ACT {
wrapItemAndSub = <li class="active">|</li>
}
CURIFSUB < .IFSUB
CURIFSUB = 1
CURIFSUB {
wrapItemAndSub = <li class="active dropdown">|</li>
}
}
}
page.20 = HMENU
page.20.special = directory
page.20.entryLevel = 0
page.20.maxItems = 6
page.20 {
1 = TMENU
1 {
wrap = <div class="row"><div class="tab-content">|</div></div>
noBlur = 1
expAll = 1
NO.doNotShowLink = 1
}
# second level
2.maxItems = 5
2 = TMENU
2.stdWrap.wrap = <div class="tab-pane fade in active pull-right" id="item-{register:count_MENUOBJ}"><nav class="navbar navbar-default pull-right submenu" role="navigation"><ul class="nav navbar-nav in">|</ul></nav></div>
2.stdWrap.wrap.insertData = 1
2{
expAll = 1
NO{
ATagTitle.field = title
wrapItemAndSub = <li>|</li>
}
IFSUB = 1
IFSUB{
ATagTitle.field = title
wrapItemAndSub = <li>|</li>
}
}
}
In the first menu block links has the correct value: data-target="#item-1", data-target="#item-2" etc..
In the second block the all links are generated in this form: id="item-5" staring and ending on item-5
Any suggestions?
register:count_MENUOBJ is counting the menu-items in the context where it's used.
In the first menu it's used in the context of the main-items and therefore counting in the natural order of the menu-items like an index. This might be the reason that the function of register:count_MENUOBJ is still confusing, even usable in that context.
In the second menu register:count_MENUOBJ is used in the context of the sub-menu items and counting the sub-items on level 2. So if on level two are 3 sub-items the register is 3. If 5 sub-items it's 5. In this context register:count_MENUOBJ is not usable as index as the amount of sub-items never reflects the expected value according to the question.
Therefore to get unique id's it's common practice to use p{field:uid} for pages or for content-elements c{field:uid}.
Example:
...
NO.wrapItemAndSub = <li id="nav-main-p{field:uid}">|</li>
NO.wrapItemAndSub.insertData = 1
...
Another alternative is to use register:count_MENUOBJ in the second menu also on the first level. Question if the menu in the question would have the required properties then.
Use the MenuProcessor instead of HMENU. I always had problems with the custom rendering of HMENU and than i turned to MenuProcessor because the html markup may be created directly in fluid.
Typoscript:
page = PAGE
page.10 = FLUIDTEMPLATE
page.10 {
...
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\MenuProcessor
10 {
as = navigationMain
}
}
}
FLUID:
<f:for each="{navigationMain}" as="menuItem">
<!-- There you have access to menu items -->
</f:for>
Documentation: https://docs.typo3.org/typo3cms/SitePackageTutorial/MainMenuCreation/Index.html
In general #David already gave all relevant information.
For clarification and as hint for an easier implementation:
In your example you used the count register in page.20.2.stdWrap.wrap. this Wrap is executed in context of second level menu, but after the menu is allready generated, so it contains the number of elements in this menu level.
You need to use the count register in first level, and so it is a wrap to the second level you can use it in .1.IFSUB.wrapItemAndSub, as you have no content in first level it will be a wrap only for the second level menu.
And also mentioned from #David:
You also could use the uids from the pages itself.
Use it in page.10, and in page.20.2 you could use the field pid from any page on that level.
As you want to use it out of the context of a menuItem you might get the problem: there is no real field pid. Either you do the wrap on the first page/ menuItem (hint: optionsplit) or do it in the first level again.
(I doubt that for .1.stdWrap you are in the context of the first level page, so you could use field uid.)
you probably have to insert the following (not tested):
page.15 = RESTORE_REGISTER
just before page.20 = HMENU ... normally used in combination with LOAD_REGISTER but it looks as if your second HMENU has the count_MENUOBJ stuck at the last value of the first ...

Getting Pagecontent in HMENU

i'm creating a menu with HMENU in Typoscript. Now my question: is there a possibility to check if the linked paged as any content. if it has none how can i disable the link?
i'm generate the menu with the following code
NAV = HMENU
NAV{
entryLevel = 0
wrap = <ul class="nav">|</ul>
1 = TMENU
1.NO {
allWrap = <li class="nav-button"><p class="title">|</p></li>
}
1.ACT = 1
1.ACT {
allWrap = <li class="nav-button selected"><p class="title">|</p></li>
}
}
Untested!
You can check with numRows if there is any tt_content record on that page (you can use WHERE if you want to check only specific records). With required you define, that this menu item will only be rendered if numRows is greater then 1.
NAV.1.NO.allStdWrap.required.numRows {
table = tt_content
select {
# uid of this page, is the pid of the records to look for
pidInList.field = uid
}
}
NAV.1.ACT.allStdWrap < NAV.1.NO.allStdWrap