原文鏈接:https://www.whongbin.cn/index/article/detail/id/41.html
- f:base
示例:
<f:base />
輸出:
<base ></base>
- f:cObject
示例:
<f:cObject typoscriptObjectPath="lib.calc" data="45 + 34 * 2" />
配置:
lib.calc = TEXT
lib.calc {
current = 1
prioriCalc = 1
}
輸出:
158
注意:Typo3中 prioriCalc忽略了\的優(yōu)先級(jí),所以真實(shí)計(jì)算公式是(45 + 34)\ 2。
- f:count
示例:
<f:count subject="{myarray}" />
<f:if condition="{myarray -> f:count()} > 3">
myarray數(shù)量與3比較
</f:if>
輸出:整數(shù)
- f:debug
示例:
<f:debug title="打印輸出變量MyArray">{myarray}</f:debug>
<f:debug title="打印輸出所有變量">{_all}</f:debug>
輸出:輸出對(duì)象或數(shù)組并打印在頁(yè)面上
- f:for
示例:
<ul>
<f:for each="{shoppinglist}" as="food" key="number" iteration="itemIteration">
<li class="item{f:if(condition: itemIteration.isFirst, then: ''first-child'')}">{number}: {food}</li>
</f:for>
</ul>
輸出:
</ul>
<li class="item first-child">4: apples</li>
<li class="item">3: choclate</li>
<li class="item">25: beer</li>
<li class="item">10: frozen pizza</li>
</ul>
可使用的迭代值:
itemIteration.index (0索引)
itemIteration.cycle (同上修肠,但是從1開(kāi)始)(1索引)
itemIteration.total (循環(huán)項(xiàng)總數(shù))
itemIteration.isFirst (第一項(xiàng)存在為真)
itemIteration.isLast (最后一項(xiàng)存在為真)
itemIteration.isOdd (奇循環(huán) cycles 1,3,5,...)
itemIteration.isEven (偶循環(huán) cycles 2,4,6,...)
- f:form
示例:
<f:form action="...">...</f:form>
<f:form action="..." controller="..." package="..." enctype="multipart/form-data"> ... </f:form>
輸出:輸出HTML表單。數(shù)據(jù)是通過(guò)POST請(qǐng)求提交的(可以通過(guò)設(shè)置
method=''get''
來(lái)更改)煎殷。表單內(nèi)容請(qǐng)看下一篇文章 使用強(qiáng)大的fluid標(biāo)簽生成表單內(nèi)容
- f:if, f:then, f:else
示例1-判斷存在:
<f:if condition="{myvar}">
不是空字符串也不是0
</f:if>
<f:if condition="{myvar}">
<f:then>不是空字符串也不是0</f:then>
<f:else>空字符串或0</f:else>
</f:if>
<section class="{f:if(condition: record.show, then: ''visible-record'', else: ''hide'')}">
示例2-比較運(yùn)算:
<f:if condition="{myvar} == ''foobar''">
變量等于字符串‘foobar’可見(jiàn)
</f:if>
{f:if(condition:''{variable}==\\''foo\\'''', then:''Hello'')}
{f:if(condition:''{variable}=="foo"'', then:''Hello'')}
<f:if condition="{rank} > 100">
如果變量值大于100時(shí)顯示為真
</f:if>
<f:if condition="{rank} % 2">
如果變量對(duì)2取余不等于0時(shí)顯示為真
</f:if>
<f:if condition="{rank} == {k:bar()}">
如果變量值等于ViewHelper函數(shù){k:bar()}的返回值時(shí)顯示為真 ViewHelper "k:bar"
</f:if>
{f:if(condition:''{number}==1'', then:''Hello'')}
<f:if condition="{enable} == 1">真</f:if>
<f:if condition="{enable} == 0">假</f:if>
{f:if(condition: enable, then: ''真'')}
{f:if(condition: ''{enable}==0'', then: ''假'')}
配合ViewHelper使用
<f:if condition="<f:count subject=''{post.comments}'' /> > 0">
<f:then>為真</f:then>
<f:else>為假</f:else>
</f:if>
多條件判斷
<f:if condition="({variableOne} && {variableTwo}) || {variableThree} || {variableFour}">
如果變量1和2為真,或者3,4,5變量為真即為真
</f:if>
輸出:做為判斷使用腿箩,可返回變量豪直,也可以返回固定值
- f:switch
示例:
<f:switch expression="{person.gender}">
<f:case value="1">{person.lastName}1</f:case>
<f:case value="2">{person.lastName}2</f:case>
<f:case value="3">{person.lastName}3</f:case>
<f:defaultCase>默認(rèn)</f:defaultCase>
</f:switch>
輸出:對(duì)應(yīng)條件的值
- f:image
示例:
<f:image src="uploads/pics/myImage.png" width="200" height="150" alt="My Image" />
<f:image src="{f:uri.resource(path:''Images/myImage.png'')}" width="200" height="150" alt="My Image" />
輸出:
<img src="http://www.examlpe.com/Images/myImage.png" width="200" height="150" alt="My Image" />
再說(shuō)一句
以上都說(shuō)了下typo3中常用的一些fluid標(biāo)簽,下片文章中我會(huì)再說(shuō)一下form表單有關(guān)的和
a
標(biāo)簽有關(guān)的fluid標(biāo)簽.'