Skip to content

Instantly share code, notes, and snippets.

@PetraMotz
Last active August 4, 2021 11:10
Show Gist options
  • Save PetraMotz/ed4fea2f51e57a058091d2e1d4e59287 to your computer and use it in GitHub Desktop.
Save PetraMotz/ed4fea2f51e57a058091d2e1d4e59287 to your computer and use it in GitHub Desktop.
Typo3 Foreach #iterator #alias #foreach #chunk #explode #fluid
###################alias#########################
<f:alias map="{firstName: address.firstName, lastName: address.lastName}">
<p>Hello, my name is {firstName} {lastName}</p>
</f:alias>
<f:alias map="{amount: '{addresses->f:count()}'}">
<p>There are {amount} records in database</p>
</f:alias>
<f:alias map="{firstName: 'Stefan', lastName: 'Froemken'}">
<p>Hello, my name is {firstName} {lastName}</p>
</f:alias>
f:alias
This ViewHelper creates variables that you can use when developing Fluid views. You create variables which contain either static values or dynamic values from objects or other ViewHelpers.
Details
map
Variable type
Array
Description
The key is the name by which the variable is known, where the value reflects the content.
Default value
Mandatory
Yes
#################chunk#################
<f:for each="{room.images -> v:iterator.chunk(count: 3)}" as="imagerow" iteration="cycle">
<div class="MasonryRow">
<f:for each="{imagerow}" as="image" iteration="imageIteration">
<img src='<f:uri.image src="{image.uid}" treatIdAsReference="1" width="730" height="360" />
</f:for>
</div>
</f:for>
<f:for each="{v:iterator.explode(content: '{field.title -> f:format.nl2br()}', glue: '<br />')}" as="part" iteration="i">
<div class="new-headerslider-title-line {f:if(condition: '{i.isFirst}', then: '', else:'mt-2')}">
<span class="new-headerslider-title d-inline-block {field.titleSize} {field.titleBackgroundcolor}">{part}</span>
</div>
</f:for>
9:34
https://git.web-crossing.com/snippets/82
##############key value####################
<f:for each="{employees}" as="employee" key="itemkey"
reverse="false" iteration="iterator">
<tr>
<td>{employee.first_name}</td>
<td>{employee.city} </td>
<td>{itemkey} </td>
<td>{iterator.index} </td>
<td>{iterator.cycle} </td>
<td>{iterator.isFirst} </td>
<td>{iterator.isLast} </td>
<td>{iterator.isOdd} </td>
<td>{iterator.isEven} </td>
<td>{iterator.total} </td>
</tr>
</f:for>
################sort#####################
<f:for each="{kunden->v:iterator.sort(order: 'ASC', sortBy: 'name')}" as="kunde">
<tr>
<f:for each="{myext:misc.explode(string:'{settings.list.fields}')}" as="field">
<f:render partial="Kunde/List/{myext:misc.upper(string:'{field}')}" arguments="{_all}" />
</f:for>
</tr>
</f:for>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment