Document parameter filtering is only available on the document home page or document category templates, and is used in combination with document pagination lists.
Description: Used for list combination filtering based on various document parameters, such as when creating a real estate website, you can filter by house type as residential, commercial, or residential-commercial, and also by house size as single room, one bedroom one living room, two bedrooms two living rooms, three bedrooms two living rooms, etc. In this case, the document parameter filtering function can be used.
Usage:{% archiveFilters 变量名 with allText="全部" %}
If a variable is defined as filters{% archiveFilters filters with allText="全部" %}...{% endarchiveFilters %}
Parameters supported by archiveFilters:
- Model ID
moduleId
moduleId
Can get the parameter filtering of a specified model,moduleId="1"
Retrieve the parameters for filtering article models. - All keywords
allText
allText
Set all keywords as text content, such as 'All', if you do not want to display, then setallText=false
. - Site ID
siteId
siteId
Generally, it is not necessary to fill in. If you have created multiple sites using the multi-site management on the backend and want to call data from other sites, you can do so by specifyingsiteId
To implement the call to data from a specified site.
The `filters` variable is an array object that needs to be output through afor
loop. The structure of the `item` object is:
- Parameter name
Name
- Parameter field name
FieldName
- Optional values for this parameter
Items
Items
is an array object, which needs to be accessed usingfor
loop to output. The object structure for 'for val' is:- Filtering value
Label
- Filtering value link
Link
- Selected or not
IsCurrent
- Filtering value
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 list of property documents, documents can be displayed through various filtering conditions, as shown in the figure:
Example of calling code (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>