简体   繁体   中英

TYPO3: HMENU not working in foreign language

The footer menu is defined as follows:

temp.footerNav = HMENU
temp.footerNav {
  special = userfunction
  special.userFunc = \MyNamespace\Helper->footerNavArray

  wrap = <ul>|</ul>

    1 = TMENU
    1 {
        wrap = |
        expAll = 0

        NO = 1
        NO.ATagParams = class="footer-navigation-link"
        NO.stdWrap.htmlSpecialChars = 1
        NO.wrapItemAndSub = <li class="footer-navigation__item">|</li>
        NO.stdWrap.field = title // nav_title
    }
}

The array returned by the function footerNavArray looks good in both German

array (size=7)
  0 => 
    array (size=2)
      'title' => string 'Unternehmen' (length=11)
      '_OVERRIDE_HREF' => string 'de/unternehmen.html' (length=19)
    ...
  ...

and English:

array (size=7)
  0 => 
    array (size=2)
      'title' => string 'Company' (length=7)
      '_OVERRIDE_HREF' => string 'en/company.html' (length=15)
    ...
  ...

The footer menu works perfectly in English (default language), however, the only output I can see on the German page (L=1) is <ul></ul> .

Any ideas?

First of all, the above behaviour was caused by [FE][hidePagesIfNotTranslatedByDefault] = 1 , which is required by Solr for TYPO3 to work correctly in a multi-language site. By adding '_SAFE' = true to the menu array, I was finally able to solve the problem:

array (size=7)
  0 => 
    array (size=3)
      'title' => string 'Company' (length=7)
      '_OVERRIDE_HREF' => string 'en/company.html' (length=15)
      '_SAFE' => boolean true
    ...
  ...

I've found the solution in line 1213 (core version 7.6.2) of TYPO3\\CMS\\Frontend\\ContentObject\\Menu\\AbstractMenuContentObject->filterMenuPages() :

you can also use global env condition for different language.

#setup the default language in case of bad L variable
config.sys_language_mode = content_fallback
config.uniqueLinkVars=1
config.sys_language_overlay = 1
config.sys_language_uid = 0
config.language = en
config.linkVars = L
# Spanish language, sys_language.uid = 1
[globalVar = GP:L = 1]
config.sys_language_uid = 1
config.language = es
config.locale_all = spanish
[global]
# English language, sys_language.uid = 0
[globalVar = GP:L = 0]
config.sys_language_uid = 0
config.language = en
[global]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM