document parameter filter tag

Document parameter filtering can only be used on the document homepage or document category template, combined with document pagination list.

Instructions: Used to create a list combination filter based on various document parameters, such as when creating a real estate website, you can filter according to house types such as residential, commercial, and mixed-use, and at the same time, you can also add additional filtering based on house size such as single room, one bedroom living room, two bedrooms living room, three bedrooms living room, etc. In this case, you can use the document parameter filtering function.

Usage:{% archiveFilters 变量名 with allText="全部" %}If the variable is defined as filters{% archiveFilters filters with allText="全部" %}...{% endarchiveFilters %}

The parameters supported by archiveFilters are:

  • Model IDmoduleId
    moduleIdCan obtain parameter filtering for a specified model, such asmoduleId="1"Get the parameter filtering of the article model.
  • All keywordsallText
    allTextSet all keywords to text content, such as “all”, if you do not want to display, then setallText=false.
  • Whether to display category filteringshowCategory showCategorySet whether to display category filtering, default isfalse
  • Category filtering of the parent category IDparentId parentIdDefault to0Indicates that all categories are retrieved if specifiedparentIdThen only the child categories of the specified category are retrieved,parentId="parent"Indicates that the sibling categories are retrieved.showCategory=trueonly takes effect when it is.
  • Site IDsiteId
    siteIdGenerally, 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.

The filters variable is an array object, it needs to be output through a loop.forThe object structure of for item is:

  • Parameter NameName
  • Parameter Field NameFieldName
  • The optional values of this parameterItems ItemsIs an array object, needs to be output throughforLoop. The object structure of for val is:
    • Filter valueLabel
    • Filter value linkLink
    • Is selectedIsCurrent

Code example

{# 参数筛选代码 #}
<div>
    <div>参数筛选:</div>
    {% archiveFilters filters with moduleId="1" allText="默认" %}
        {% for item in filters %}
        <ul>
            <li>{{item.Name}}: </li>
            {% for val in item.Items %}
            <li class="{% if val.IsCurrent %}active{% endif %}"><a href="{{val.Link}}">{{val.Label}}</a></li>
            {% endfor %}
        </ul>
    {% endfor %}
    {% endarchiveFilters %}
</div>

{# 文档列表代码 #}
<div>
{% archiveList archives with moduleId="1" type="page" limit="10" %}
    {% for item in archives %}
    <li>
        <a href="{{item.Link}}">
            <h5>{{item.Title}}</h5>
            <div>{{item.Description}}</div>
            <div>
                <span>{% categoryDetail with name="Title" id=item.CategoryId %}</span>
                <span>{{stampToDate(item.CreatedTime, "2006-01-02")}}</span>
                <span>{{item.Views}} 阅读</span>
            </div>
        </a>
        {% if item.Thumb %}
        <a href="{{item.Link}}">
            <img alt="{{item.Title}}" src="{{item.Thumb}}">
        </a>
        {% endif %}
    </li>
    {% empty %}
    <li>
        该列表没有任何内容
    </li>
    {% endfor %}
{% endarchiveList %}

    {# 分页代码 #}
    <div>
        {% pagination pages with show="5" %}
            {# 首页 #}
            <a class="{% if pages.FirstPage.IsCurrent %}active{% endif %}" href="{{pages.FirstPage.Link}}">{{pages.FirstPage.Name}}</a>
            {# 上一页 #}
            {% if pages.PrevPage %}
            <a href="{{pages.PrevPage.Link}}">{{pages.PrevPage.Name}}</a>
            {% endif %}
            {# 中间多页 #}
            {% for item in pages.Pages %}
            <a class="{% if item.IsCurrent %}active{% endif %}" href="{{item.Link}}">{{item.Name}}</a>
            {% endfor %}
            {# 下一页 #}
            {% if pages.NextPage %}
            <a href="{{pages.NextPage.Link}}">{{pages.NextPage.Name}}</a>
            {% endif %}
            {# 尾页 #}
            <a class="{% if pages.LastPage.IsCurrent %}active{% endif %}" href="{{pages.LastPage.Link}}">{{pages.LastPage.Name}}</a>
        {% endpagination %}
    </div>
</div>

Common usage examples

In a real estate document list, you can display documents through various filtering conditions, as shown in the figure:

detail-3

Call code example (code does not include css style control)

<div>
    <div>房产筛选:</div>
    {% archiveFilters filters with moduleId="1" allText="不限" %}
        {% for item in filters %}
        <ul>
            <li>{{item.Name}}: </li>
            {% for val in item.Items %}
            <li class="{% if val.IsCurrent %}active{% endif %}"><a href="{{val.Link}}">{{val.Label}}</a></li>
            {% endfor %}
        </ul>
    {% endfor %}
    {% endarchiveFilters %}
</div>