Home Banner List Tags

Description: Used to get the home page 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 typeDefault value "default", you can create multiple banner groups in the background thentype="分组名"Call different group banners.

banners are array objects, so they need to be usedforLoop to output

item is the variable within the for loop, the available fields are:)

  • IDId
  • Logo image addressLogo
  • Link addressLink
  • introduceDescription
  • Image 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 %}

To determine if the current is the first item 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 %}