[TYPO3-mvc] access to ChildNodes arguments
Christian Zenker
christian.zenker at 599media.de
Fri Jul 31 11:42:52 CEST 2009
Am 31.07.2009, 11:17 Uhr, schrieb Sebastian Kurfürst
<sebastian at typo3.org>:
Hi.
> But nevertheless, I think we should see what the real use-case for this
> is.
Sure:
I use it to switch between different views, selected in a flexform. I
know, the controller should switch the views, but the views share some
code, and I'd prefer to change it in one file rather than 4. It looks like
that:
[...]
<x:switch by="{useLayout}">
<x:case label="list">
<div class="cont">
<ul>
<f:for each="{products}" as="product">
<li><p><f:link.action pageUid="25" pluginName="PiDisplay"
action="show" controller="Product" arguments="{product :
product}">{product.title}</f:link.action></p></li>
</f:for>
</ul>
</div>
</x:case>
<x:case label="dropdown">
<div class="cont">
# you should ignore this ;)
<x:form method="get" pageUid="25">
<f:form.hidden name="tx_fiproductdisplay_pidisplay[controller]"
value="Product" />
<f:form.hidden name="tx_fiproductdisplay_pidisplay[action]"
value="show" />
<f:form.select name="tx_fiproductdisplay_pidisplay[product][uid]"
options="{products}" optionValueField="uid" optionLabelField="title" />
<f:form.submit value="{f:translate(key='show')}" />
</x:form>
</div>
</x:case>
<x:case label="fisheye">
<div id="fisheye-container"><table class="fisheye"><tr>
<f:for each="{products}" as="product">
<f:if condition="{product.headerImg}">
<td class="fisheye"><f:link.action pageUid="25" pluginName="PiDisplay"
action="show" controller="Product" arguments="{product :
product}"><x:fishEyeItem class="fisheye-img"
src="uploads/tx_fiproductdisplay/{product.headerImg}"
alt="{product.title}" title="{product.title}" maxWidth="150"
maxHeight="250" /><p class="fisheye-label
align-center">{product.title}</p></f:link.action></td>
</f:if>
</f:for>
</tr></table></div>
</x:case>
<x:default>
<f:for each="{products}" as="product">
<h2 class="orange">{product.title}</h2>
<f:if condition="{product.headerImg}">
<x:loadTS
typoscriptPath='lib.productPic.file.10.file'>uploads/tx_fiproductdisplay/{product.headerImg}</x:loadTS>
<f:image class="float-right"
src="{f:cObject(typoscriptObjectPath='lib.productPic')}"
alt="{product.title}" />
</f:if>
<div class="cont"><f:format.html>{product.teaser}</f:format.html></div>
<p><f:link.action class="more" pageUid="25" pluginName="PiDisplay"
action="show" controller="Product" arguments="{product :
product}"><f:translate
key="productsShow">show</f:translate></f:link.action></p> </f:for>
</x:default>
</x:switch>
[...]
But it might also come in handy when iterating over objects, e.g.:
<f:for each="{items}" as="item">
<x:switch by="{item.layout}">
<x:case label="highlight">
<p style="color:red">{item.text}</p>
</x:case>
<x:case label="larger">
<p style="font-size:larger">{item.text}</p>
</x:case>
<x:default>
<p>{item.text}</p>
</x:default>
</x:switch>
</f:for>
Christian.
More information about the TYPO3-project-typo3v4mvc
mailing list