Loop on module data
Loop syntax
todo
Loop filters
todo
Loop index
{loop_index}
will show you the index of the element in the loop. It starts counting at 1
$loop|{room}|{a}| $#
{loop_index}
$/loop|{room}|{a}| $#
Example to know if the element is odd / even
$loop|{room}|{a}| $#
Loop index = {loop_index} - {if="'{loop_index}' % 2 == '0'"}even{else}odd{/if}
$/loop|{room}|{a}| $#
Count results
To get the number of items from a collection, here is the syntax: #$count|RULES_FOR_LOOP$#
Use #$count|{{item.hotel_number}}$# if your loop is :
#$loop|{{item.hotel_number}}|{a}| $#
#$/loop|{{item.hotel_number}}|{a}| $#
Use #$count|{hotel,[is_featured=1]}$# if your loop is:
#$loop|{hotel,[is_featured=1]}|{a}| $#
#$/loop|{hotel,[is_featured=1]}|{a}| $#
Always check that your result if coherent. (the feature still in beta)
Currently, the count feature doesn't work with CMS variable. So #$count|{hotel,[limit=#$variable|limit$#]}$#
won't count correctly
Fix context issues
If you do a loop on a shared module (for example offers are shared across hotels, events are shared), in a detail page, there is a risk that it will show offers of another hotel from the same master brand
This is because detail pages changes the context for Galaxy, to be able for example to get only the rooms of a specific hotel on a hotel detail page.
To fix this, there is a custom filter you can add that will force the loop to use the context of the website, instead of the context of the page: item--website
#$loop|{offer,[item--website=1]}|{a}| $#
{a.name}
#$/loop|{offer,[item--website=1]}|{a}| $#
Last updated