我将从我试图开展工作的片段开始......
我在constants.ts中定义社交帐户:
myExtension.configuration {
socials {
# cat=myExtension/socials/05; type=string; label=Facebook account:
facebook = facebook.com/
# cat=myExtension/socials/10; type=string; label=Twitter account:
twitter = twitter.com/
# cat=myExtension/socials/15; type=string; label=Google Plus account:
googlePlus = plus.google.com/
# cat=myExtension/socials/20; type=string; label=Youtube account:
youtube = youtube.com/
}
}
我在page.ts中声明变量
page = PAGE
page {
# Page Main template
10 = FLUIDTEMPLATE
10 {
file = EXT:myExtension/Resources/Private/Templates/Main.html
variables {
socials = TEXT
socials.value = {$myExtension.configuration.socials}
}
}
}
然后我尝试在模板中使用它:
<f:render section="socials" />
<f:section name="socials">
<ul class="list-inline hidden-print">
<f:for each="{socials}" as="social" key="icon">
<li>
<a href="{social}">
<i class="fa fa-{icon} fa-fw">
</a>
</li>
</f:for>
</ul>
</f:section>
我对typo3还不是很好,所以它可能非常简单,或者问题非常愚蠢......我甚至没有弄清楚如何正确调试(这样我首先可以弄清楚如何确保变量数组&#39; socials&#39;)...
答案 0 :(得分:2)
首先,您需要逐个获取常量(按照j4k3的建议) - 或者完全跳过该部分并直接定义这样的值:
page = PAGE
page {
# Page Main template
10 = FLUIDTEMPLATE
10 {
file = EXT:myExtension/Resources/Private/Templates/Main.html
variables {
facebook = TEXT
facebook.value = facebook.com/
twitter = TEXT
twitter.value = twitter.com/
googlePlus = TEXT
googlePlus.value = plus.google.com/
youtube = TEXT
youtube.value = youtube.com/
}
}
}
然后,为了避免重复代码,您可以通过首先映射它们然后迭代来访问这些值:
<f:alias map="{socials: {facebook: facebook, twitter: twitter, googlePlus: googlePlus, youtube: youtube}}">
<f:render section="socials" arguments="{socials: socials}"/>
</f:alias>
<f:section name="socials">
<ul class="list-inline hidden-print">
<f:for each="{socials}" as="social" key="icon">
<li>
<a href="{social}">
<i class="fa fa-{icon} fa-fw">
</a>
</li>
</f:for>
</ul>
</f:section>