Unit Data

To dynamize the theme, we have two different way to fetch content - CMS variables and Unit Data -

When we talk about unit data, it's refer to the Data section of the BO. For example POI, Restaurant, Weddings, Offers etc.

You can manage unit data depending of context. For example, imagine you are in your hotel context and you need to display all its available rooms.

#$loop|{room}|{a}| $#
    <img src="{a.first_photo.url_square}" alt="{a.first_photo.alt}">
    <h3>{a.name}</h3>
    {a.short_description}
    {if=" '{a.url}' "}
        <a href="{a.url}">__@@Learn More@@__</a>
    {/if}
#$/loop|{room}|{a}| $#

This code allow you to fetch all the available rooms. For each of them you'll display, a photo, its name, its short description and the link to its detail page.

Keys like short_description, url, name etc. have been created by our back team. If you don't know how to fetch a data you can ask us, but most of the time, we used the same.

Now, if you are in the room detail page context for exemple, you don't need to loop on all the room. The system already know that you want to fetch the data of a specific room.

<h3>{{item.name}}</h3>
#$loop|{{item.photos}}|{photo}| $#
    <img src="{photo.url_wide}" alt="{photo.alt}">
#$/loop|{room}|{a}| $#
{{item.short_description}}

If you go to the detail page of My First Room, this code will return you:

<h3>My First Room</h3>
<img src="https://photo1.jpg" alt="photo1">
<img src="https://photo2.jpg" alt="photo2">
Adolescebat autem obstinatum propositum erga haec et similia multa scrutanda, 
stimulos admovente regina, quae abrupte mariti fortunas trudebat in exitium 
praeceps, cum eum potius lenitate feminea ad veritatis humanitatisque viam 
reducere utilia suadendo deberet, ut in Gordianorum actibus factitasse Maximini 
truculenti illius imperatoris rettulimus coniugem.

Count results from a list

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}| $#

Display edit module items button

When using unit data in a block or a list, you can specify the related module's name in the tester.

By doing this, if the module name is valid, it will add an icon next to the block name and a button to access directly to the concerned unit overview page.

Valid modules'name are those listed in the data section of the navbar.

Last updated