I have a multilingual site built with TYPO3 V7.6.18. It uses a slogan which should remain editable but different for three languages. This is a variable that is hard-coded in the Fluid templates.
For variables of this kind I use a file Configuration/TypoScript/constants.ts
where I define the variable that can be edited (WEB -> Template -> Constant Editor
) and used:
#---------------------------------------------------------------------
# constants.ts
#---------------------------------------------------------------------
# customsubcategory=general=General Setup
myextension.configuration {
general {
# cat=myextension/general/05; type=string; label=Website Slogan.
slogan= website slogan in main language
}
}
[globalVar = GP:L=1]
myextension.configuration.general.slogan = website slogan in second language
[end]
[globalVar = GP:L=2]
myextension.configuration.general.slogan = website slogan in third language
[end]
I then bind the variable in Configuration/TypoScript/setup.ts
for use:
#---------------------------------------------------------------------
# setup.ts
#---------------------------------------------------------------------
page = PAGE
page {
# Page Main template
10 = FLUIDTEMPLATE
10 {
variables {
# slogan
slogan = TEXT
slogan.value = {$myextension.configuration.general.slogan}
}
}
}
This code works, but only the slogan in the main language is editable ...
Any solution to make the slogans editable in the other two languages?
Three possibilities suggest themselves, two of which were mentioned by Mathias and Riccardo. I‘ll add a third one an list pros and cons of them.
So, firstly the third possibility which is to create a content element (preferably of type header
) and create a TypoScript constant holding its uid
.
# cat=myextension/general/05; type=int; label=Slogan CE UID
myextension.configuration.general.sloganUid =
Then fetch this content element‘s header in your fluid variable:
page.10.variables.slogan = CONTENT
page.10.variables.slogan {
select.uidInList = {$myextension.configuration.general.sloganUid}
table = tt_content
renderObj = TEXT
renderObj.field = header
}
Create a sysfolder, create a content element of type header and plumb its uid in your constant. Maybe you‘ll have to add some more stuff to .select
to make it work - I‘m always unsure that.
Now pros and cons:
I'd recommend to use language identifiers for the constants instead:
myextension.configuration {
general {
slogan {
# cat=myextension/general/05; type=string; label=Website Slogan in default language.
default = website slogan in main language
# cat=myextension/general/06; type=string; label=Website Slogan in second language.
second = website slogan in second language
# cat=myextension/general/07; type=string; label=Website Slogan in third language.
third = website slogan in third language
}
}
}
Then move the condition to the setup:
page = PAGE
page {
# Page Main template
10 = FLUIDTEMPLATE
10 {
variables {
# slogan
slogan = TEXT
slogan.value = {$myextension.configuration.general.slogan.default}
}
}
}
[globalVar = GP:L=1]
page.10.variables.slogan.value = {$myextension.configuration.general.slogan.second}
[end]
[globalVar = GP:L=2]
page.10.variables.slogan.value = {$myextension.configuration.general.slogan.third}
[end]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With