Description: Used to get the home banner list
Usage:{% bannerList 变量名称 %}If the variable is defined as banners{% bannerList banners %}...{% endbannerList %}
The parameters supported by bannerList are:
- Site ID
siteIdsiteIdGenerally, it is not necessary to fill in. If you have created multiple sites using the multi-site management on the backend and want to call data from other sites, you can do so by specifyingsiteIdTo implement the call to data from a specified site. - Group name
typetypedefault value. You can create multiple banner groups in the background, and then call different groups' banners bytype="分组名"to call banners from different groups.
banners is an array object, so it needs to be usedforin a loop to output
item is the variable within the for loop, available fields include:
- ID
Id - Logo image address
Logo - Link address
Link - Introduction
Description - Image Alt
Alt
Code example
{% bannerList banners %}
{% for item in banners %}
<a href="{{item.Link}}" target="_blank">
<img src="{{item.Logo}}" alt="{{item.Alt}}" />
<h5>{{item.Title}}</h5>
</a>
{% endfor %}
{% endbannerList %}
Call the specified group, such as the group name is 'Slide'
{% bannerList banners with type="幻灯" %}
{% for item in banners %}
<a href="{{item.Link}}" target="_blank">
<img src="{{item.Logo}}" alt="{{item.Alt}}" />
<h5>{{item.Title}}</h5>
</a>
{% endfor %}
{% endbannerList %}
To determine if the current iteration is the first in a loop, you can write it like this: {% if forloop.Counter == 1 %}This is the first item{% endif %} For example, if you need to add an extra class='active' to the first item, you can write it like this:
{% bannerList banners %}
{% for item in banners %}
<a class="{% if forloop.Counter == 1 %}active{% endif %}" href="{{item.Link}}" target="_blank">
<img src="{{item.Logo}}" alt="{{item.Alt}}" />
<h5>{{item.Title}}</h5>
</a>
{% endfor %}
{% endbannerList %}