# Unit Data

{% hint style="info" %}
When we talk about unit data, it's refer to the **Data** section of the BO. For example POI, Restaurant, Weddings, Offers etc.
{% endhint %}

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.

```markup
#$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.

{% hint style="info" %}
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.
{% endhint %}

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.&#x20;

```markup
<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:

```markup
<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$#`

```markup
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.&#x20;

![](https://3028197268-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LYM6a76uZePOTen0dIw-887967055%2Fuploads%2FhLWTK6x3ilGcOS5HGufr%2FCapture%20d%E2%80%99e%CC%81cran%202022-01-11%20a%CC%80%2017.56.20.png?alt=media\&token=96ceafdd-e00d-4bdd-95c0-161f0c3385fe)

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.

![](https://3028197268-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LYM6a76uZePOTen0dIw-887967055%2Fuploads%2FESumGyF0o3A4bsHeqXEn%2FCapture%20d%E2%80%99e%CC%81cran%202022-01-11%20a%CC%80%2018.00.45.png?alt=media\&token=5559b388-67cf-4865-9cb3-7959f76f592d)

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

![](https://3028197268-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LYM6a76uZePOTen0dIw-887967055%2Fuploads%2F4gK2u0zUFdp9VDF9D5zB%2FCapture%20d%E2%80%99%C3%A9cran%202022-01-11%20%C3%A0%2014.05.22.png?alt=media\&token=3ba746e8-b48e-462a-8e12-5a5be89e1cd4)
