Description: Used to get the home banner list
Usage:{% bannerList 变量名称 %}If the variable is defined as banners{% bannerList banners %}...{% endbannerList %}
bannerList supports the following parameters:
- Site ID
siteIdsiteIdGenerally, it is not necessary to fill in, if you use the multi-site management on the backend to create multiple sites and want to call data from other sites, you can specifysiteIdTo call the data of the specified site. - Group name
typetypeDefault value "default", you can create multiple banner groups in the background and then go throughtype="分组名",to call banners from different groups.
banners is an array object, so it needs to be usedforloop to output
item is the variable within the for loop, the available fields are:
- 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 "幻灯"
{% 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 %}
If you want to judge whether the current is the first in the loop, you can write it like this: {% if forloop.Counter == 1 %}This is the first{% endif %} For example, if you want to add an extra class=“active” to the first one, 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 %}