Description: Used to get the homepage Banner list
How to use:{% bannerList 变量名称 %}
If variables are defined as banners{% bannerList banners %}...{% endbannerList %}
The parameters supported by bannerList are:
- Site ID
siteId
siteId
Generally, there is no need to fill in it. If you use the background multi-site management to create multiple sites and want to call data from other sites, you can specify itsiteId
To implement the data calling the specified site. - Group name
type
type
The default value is "default", you can create multiple banner groups in the background and then usetype="分组名"
to call banners of different groups.
banners are array objects, so they need to be usedfor
Loop to output
item is a variable in the for loop body. The available fields are:
- ID
Id
- Logo image address
Logo
- Link address
Link
- introduce
Description
- Picture 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, if 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 %}
If you want to determine whether it is the first item in the loop, you can write it like this:
{% if forloop.Counter == 1 %} This is the first {% 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 %}