Last active
August 4, 2020 12:51
-
-
Save julrich/d91c1ac1968418e6ae8290f2a2e90afb to your computer and use it in GitHub Desktop.
Fully cached TYPO3 HMENU navigation example with expAll and 'active', 'current' states
Instead of using my constants {$page.uid.root}, I use {leveluid:0} now.
# Limit the L parameter to the possible language IDs!!!
# If not, a hit to an unused L parameter will write the cache for the default language E.G.:
config.linkVars = L(1-3)
lib.menu = COA
lib.menu.cache {
key.cObject = COA
key.cObject.10 = TEXT
key.cObject.10.value = lib_menu_site{leveluid:0}_lang{TSFE:sys_language_uid}
key.cObject.10.insertData = 1
key.cObject.20 = TEXT
key.cObject.20.if.isTrue.data = TSFE:fe_user|user|usergroup
key.cObject.20.data = TSFE:fe_user|user|usergroup
key.cObject.20.wrap = _groups|
key.cObject.20.insertData = 1
key.cObject.20.replacement.10.search = ,
key.cObject.20.replacement.10.replace = -
lifetime = default
}
And another nice gotcha. Should probably start revisiting our current implementation... ;)
In order to avoid listing of all pages where the resulting regular expression would be empty, like it is here done
[globalVar = TSFE:id={$page.uid.root}] || [globalVar = TSFE:id={$page.uid.404}] || [globalVar = TSFE:id={$page.uid.noTranslation}] || [globalVar = TSFE:id={$page.uid.search}]
maybe the better solution would be
page.stdWrap.replacement.10 {
search.cObject = COA
search.cObject.10 = HMENU
search.cObject.10 {
....
stdWrap.ifEmpty.cObject = TEXT
stdWrap.ifEmpty.cObject.value = somethingwhatever
stdWrap.wrap = #(|)#i
}
....
}
works for me, at least :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ah, that's really useful. Dynamic content as part of the cached menu is a common challenge here (e.g. show some part of the menu for logged in users only. Especially if you don't want to lose the performance gains completely for those cases.