Learn about the top 2016 CMS trends. Read on.


Alex Kellner of in2code recently wrote the following slick piece of TypoScript for creating a language selector menu.

lib.menu_lang = HMENU
lib.menu_lang {
	special = language
	special.value = 0,1,2,3
	special.normalWhenNoLanguage = 0
	wrap = <ul id="menu_lang">|</ul>

	1 = TMENU
	1 {
		noBlur = 1

		NO = 1
		NO {
			linkWrap =<ul><li>|</li></ul>|*|<ul><li>|</li></ul>|*|<ul><li class="last">|</li></ul>
			stdWrap.override = deutsch || english || français || español
		}

		ACT < .NO
		ACT {
			ATagParams = class="act"
		}

		USERDEF1 < .NO
		USERDEF1 {
			doNotLinkIt = 1
		}

		USERDEF2 < .ACT
		USERDEF2 {
			doNotLinkIt = 1
		}
	}
}

Notes

  • Language ids are given in special.value = 0,1,2,3 which match with the same order of the language labels found in stdWrap.override = deutsch || english || français || español.
  • The currently selected language is not clickable.

References

Still stuck? Write us.

  • Is it possible to insert html tags into “override” parameter? for example:
    stdWrap.override = deutschsomething || english || français || español

    • Adrian, I’m not sure. I’d give it a try. I’m suspecting not though. You might get an `optionSplit` or the like to help you with this if not.