Skip to content

Instantly share code, notes, and snippets.

@scheibome
Last active January 13, 2023 10:39
Show Gist options
  • Save scheibome/6659d8794d3bf8ecd2021aaf2088ac07 to your computer and use it in GitHub Desktop.
Save scheibome/6659d8794d3bf8ecd2021aaf2088ac07 to your computer and use it in GitHub Desktop.
Simple language menu in TYPO3
// Available language ids
AVAILABLELANGUAGEIDS = 0,1,2,3
<f:if condition="{menuLanguage}">
<nav class="c-languageselect">
<button class="c-languageselect__button" id="languageselectbutton">
{site.languages.{data.sys_language_uid}.navigationTitle}
<i class="icon icon-expand_more"></i>
</button>
<ul id="languageselect__list" class="c-languageselect__list">
<f:for each="{menuLanguage}" as="item">
<li class="c-languageselect__item">
<f:if condition="{item.active} == 0">
<f:if condition="{item.available} == 1">
<f:then>
<f:link.page class="c-languageselect__link" addQueryString="1" addQueryStringMethod="GET" additionalParams="{L:item.languageUid}">
{site.languages.{item.languageUid}.navigationTitle}
</f:link.page>
</f:then>
<f:else>
<span class="c-languageselect__link c-languageselect__link--unavailable">
{site.languages.{item.languageUid}.navigationTitle}
</span>
</f:else>
</f:if>
</f:if>
</li>
</f:for>
</ul>
</nav>
</f:if>
page = PAGE
page {
10 = FLUIDTEMPLATE
10 {
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\SiteProcessor
10 {
as = site
}
20 = TYPO3\CMS\Frontend\DataProcessing\MenuProcessor
20 {
special = language
special.value = {$AVAILABLELANGUAGEIDS}
as = menuLanguage
}
}
}
}
@Tuurlijk
Copy link

Tuurlijk commented Aug 28, 2020

Where does the site.languages object come from?

Aha, from the SiteProcessor

@scheibome
Copy link
Author

Aha, from the SiteProcessor

Correct. I made one more adjustment, because there was still a bug in the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment