Skip to content

Instantly share code, notes, and snippets.

@kdambekalns
Created December 21, 2017 11:03
Show Gist options
  • Save kdambekalns/1587f4d0babc646dfc0ac9b9edc147ee to your computer and use it in GitHub Desktop.
Save kdambekalns/1587f4d0babc646dfc0ac9b9edc147ee to your computer and use it in GitHub Desktop.
Provide link to "other language" only if it "exists"
prototype(Acme.AcmeCom:LanguageVariantFinder) < prototype(Neos.Fusion:RawArray) {
requestedLanguageCode = ${documentNode.context.targetDimensions.language}
otherLanguageCode = ${this.requestedLanguageCode == 'en' ? 'de' : 'en'}
otherLanguageLabel = ${this.otherLanguageCode == 'en' ? 'Englisch' : 'German'}
otherLanguageText = ${this.otherLanguageCode == 'en' ? 'Diese Seite ist auch verfügbar auf' : 'This page is also available in'}
nodeVariantsExist = ${Array.length(q(documentNode).find('main').find('[instanceof TYPO3.Neos:Content]').context({'dimensions': {'language': [this.otherLanguageCode]}, 'targetDimensions': {'language': this.otherLanguageCode}}).get()) > 0}
otherLanguageNode = ${this.nodeVariantsExist ? q(documentNode).context({'dimensions': {'language': [this.otherLanguageCode, this.requestedLanguageCode]}, 'targetDimensions': {'language': this.otherLanguageCode}}).get(0) : null}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment