Document parameter filtering can only be used on the document homepage or document classification template, combined with the document paging list.
Note: Used to perform filtering conditions for list combination screening based on various parameters of the document. For example, when building a real estate website, it can be used for residential, shop, commercial and residential purposes according to the type of house. At the same time, it can be additionally selected for single rooms, one bedroom, one living room, two bedrooms, two living rooms, three bedrooms and two living rooms, etc. according to the size of the house. In this case, the document parameter screening function can be used.
How to use:{% archiveFilters 变量名 with allText="全部" %}
Define variables as filters{% archiveFilters filters with allText="全部" %}...{% endarchiveFilters %}
The supported parameters of archiveFilters are:
- Model ID
moduleId
moduleId
You can obtain parameter filtering for the specified model, such asmoduleId="1"
Get parameter filtering for article model. - All keywords
allText
allText
Set all keywords to be text content, such as "all". If you do not want to display it, setallText=false
. - 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.
filters variable is an array object, which needs to be passedfor
Loop to output. The object structure of for item is:
- Parameter name
Name
- Parameter field name
FieldName
- Optional value for this parameter
Items
Items
is an array object that needs to be passedfor
Loop to output. The object structure for val is:- Filter values
Label
- Filter value link
Link
- Whether to select
IsCurrent
- Filter values
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, various filtering conditions can be used to display the document, as shown in the figure:
Call code example (the code does not contain 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>