Home Banner List Tags

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 IDsiteId
    siteIdGenerally, 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 itsiteIdTo implement the data calling the specified site.
  • Group nametype
    typeThe 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 usedforLoop to output

item is a variable in the for loop body. The available fields are:

  • IDId
  • Logo image addressLogo
  • Link addressLink
  • introduceDescription
  • Picture AltAlt

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 %}