[英]TYPO3: language dependent variable that is hard-coded in a Fluid template
I have a multilingual site built with TYPO3 V7.6.18 . 我有一个使用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. 这是一个在Fluid模板中硬编码的变量。
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: 对于这种变量,我使用文件Configuration/TypoScript/constants.ts
,我在其中定义了可以编辑的变量( WEB -> Template -> Constant Editor
)并使用:
#---------------------------------------------------------------------
# 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: 然后我在Configuration/TypoScript/setup.ts
绑定变量以供使用:
#---------------------------------------------------------------------
# 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. 有三种可能性,Mathias和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
. 所以,首先是第三种可能性,即创建一个内容元素(最好是类型header
)并创建一个保存其uid
的TypoScript常量。
# 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. 创建一个sysfolder,创建一个header类型的内容元素,并在你的常量中检测它的uid。 Maybe you'll have to add some more stuff to .select
to make it work - I'm always unsure that. 也许你必须添加一些东西给.select
以使它工作 - 我总是不确定。
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]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.