TYPO3 mark root page as active

非 Y 不嫁゛ 提交于 2019-12-25 11:54:19

问题


In my TYPO3 6.2.31 (I know...) page I have the following typoscript for the navigation:

NAVIMAIN = HMENU
NAVIMAIN.entryLevel = 0
#NAVIMAIN.excludeUidList = 

NAVIMAIN {
1 = TMENU
1 {
expAll = 1
wrap = <ul class="sf-menu">|</ul>
noBlur = 1

NO = 1
NO.ATagTitle.field = title
NO.wrapItemAndSub = <li>|</li>  

ACT = 1
ACT.wrapItemAndSub = <li class="active"> |</li>  

 }

2 = TMENU
2 {
expAll = 1
maxItems = 10
wrap = <div class="sf-mega">|</div>
NO = 1
NO {
  ATagTitle.field = title
  wrapItemAndSub = <div class="sf-mega-section">|</div>
  stdWrap.wrap = |
  ATagParams =  class="headermega"
  stdWrap.htmlSpecialChars = 1
  doNotLinkIt = 0
  }
}

3 = TMENU
3 {
expAll = 1
maxItems = 20
wrap = <ul>|</ul>
NO = 1
NO {
  ATagTitle.field = title
  linkWrap = <li>|</li>
}
ACT = 1
ACT {
  wrapItemAndSub = <li>|</li>
  ATagParams =  class="active"
}
}
#4 < .3

}

All sub pages are marked as aktive when they are clicked ... but the root node not ... so I've added this as well:

[globalVar = TSFE:id=1]
    NAVIMAIN.alwaysActivePIDlist = 1
[global]

[globalVar = TSFE:id=1]
    NAVIMAIN.alwaysActivePIDlist = 60
[global]

But this does hasn't any effect as well.

What can I do to mark the root node as active as well?

Thanks in advance


回答1:


After some Teamviewer investigations we found the source of the problem in the Typoscript structure. The [globalVar] condition was placed inside page.20.marks {} but conditions must be placed outside of any nesting.

Moving the condition outside of the nesting and correcting the path, everything worked fine.

[globalVar = TSFE:id=1]
    page.20.marks.NAVIMAIN.alwaysActivePIDlist = 60
[global]

As Bernd said, [page:uid = 1] would be the better condition, too.




回答2:


If you want both pages to be active you need to do another construct as in your way the second assignement would overwrite the first one.

[globalVar = TSFE:id=1]
    NAVIMAIN.alwaysActivePIDlist := addToList(1)
[global]

[globalVar = TSFE:id=1]
    NAVIMAIN.alwaysActivePIDlist := addToList(60)
[global]

In general you would join the two statements.

Another change I would consider: use another condition as TSFE will become obsolete in the near future:

[page:uid = 1]
    NAVIMAIN.alwaysActivePIDlist = 1,60
[global]


来源:https://stackoverflow.com/questions/46932881/typo3-mark-root-page-as-active

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!