Language menu¶
See also
The LanguageMenuProcessor can be used to create a language menu styled by Fluid.
Creates a language selector menu.
The special = language
type will create menu items based on
the current page record but with the language record for each language
overlaid if available.
Properties¶
Property
special.value
Data type
comma list of sys_language uids /stdWrap or auto
Description
The number of elements in this list determines the number of menu
items. Setting to auto
will include all available languages from
the current site.
Property
special.normalWhenNoLanguage
Data type
boolean
Description
If set to 1, the button for a language will be rendered as a non- disabled button even if no translation is found for the language.
[tsref:(cObject).HMENU.special = language]
Example¶
Creates a language menu with pure Typoscript:
lib.langMenu = HMENU
lib.langMenu {
special = language
special.value = 0,1,2
wrap = <ul class="langugageMenu">|</ul>
1 = TMENU
1 {
NO = 1
NO {
linkWrap = <li>|</li>
doNotLinkIt = 1
stdWrap.override = en || de || fr
stdWrap.typolink {
parameter.data = page:uid
additionalParams = &L=0 || &L=1 || &L=2
addQueryString = 1
addQueryString.exclude = L,id
}
}
// We are in the current language
ACT < .NO
ACT {
linkWrap = <li class="active">|</li>
}
// No translation available
USERDEF1 < .NO
USERDEF1 {
linkWrap = <li class="disabled">|</li>
stdWrap.typolink >
}
}
}
See also
For a langauge menu styled by Fluid see LanguageMenuProcessor.
Note on item states¶
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).