cili
cili

Reputation: 1067

Typo3: don't display language link if no translation available

I have this typoscript language menu:

tmpl.NavLang  = HMENU
tmpl.NavLang {
  special=language
  special.value = 0,1,2,3

  1 = TMENU
  1 {
    NO = 1
    NO {
      stdWrap.htmlSpecialChars = 1
      stdWrap.override = DE || EN || FR || PL
      ATagTitle = Deutsch || English || Francais || Polski
    }
    ACT < .NO
    ACT.doNotLinkIt = 1
    ACT.linkWrap = <span>|</span>
  }
}

If I am on a page in English which, for example, does not have a French translation, I want to hide FR from the menu. Is this possible?

Thanks!

Upvotes: 1

Views: 6088

Answers (2)

pgampe
pgampe

Reputation: 4578

From tsref:

When TSFE->sys_language_uid matches the sys_language uid for an element the state is set to ACT, otherwise NO. However, if a page is not available due to the pages Localization settings (which can disable translations) or if no Alternative Page Language record was found (can be disabled with .normalWhenNoLanguage, see below) the state is set to USERDEF1 for non-active items and USERDEF2 for active items. So in total there are four states to create designs for. It is recommended to disable the link on menu items rendered with USERDEF1 and USERDEF2 in this case since they are disabled exactly because a page in that language does not exist and might even issue an error if tried accessed (depending on site configuration).

So you just need to read the manual and configure the item states for USERDEF1 and USERDEF2. In your case, you would have to override them with an empty value.

Upvotes: 10

cili
cili

Reputation: 1067

Fixed by installing sr_language_menu extension and setting "showInactive" constant to 0.

Upvotes: -2

Related Questions