Description: Used to obtain a regular document list, related document list, and document paging list
How to use:{% archiveList 变量名称 with categoryId="1" order="id desc|views desc" type="page|list" q="搜索关键词" %}
If you define a variable as archives{% archiveList archives with type="page" %}...{% endarchiveList %}
The supported parameters of archiveList are:
- Model ID
moduleId
moduleId
You can get a list of documents for a specified document model, such asmoduleId="1"
Get a list of documents for the article model. - Classification ID
categoryId
categoryId
You can get a list of documents for the specified classification, such ascategoryId="1"
Get a list of documents with document classification ID 1. Multiple classification IDs are available, separated, such ascategoryId="1,2,3"
.
If not specified
categoryId
It will try to read the classification ID of the current page classification, so if you want it not to automatically read the current classification ID, you can go throughcategoryId="0"
to specify that it does not read automatically.
- Excluded Class ID
excludeCategoryId
excludeCategoryId
Documents with specified categories can be excluded, such asexcludeCategoryId="1"
Exclude documents with document classification ID 1. Multiple classification IDs are available, separated - Author ID
userId
userId
You can obtain documents published by the specified user ID, such asuserId="1"
Get the document published by a user with user ID 1. - Superior Document ID
parentId
parentId
You can obtain documents from the specified superior, such asparentId="1"
Get the document with the superior ID of 1. - Recommended attributes
flag
flag
Supported attribute values include headlines [h], recommended [c], slideshow [f], special recommendation [a], scroll [s], bold [h], picture [p], and jump [j]. If you want to display the flag attribute as recommended, the tag isflag="c"
- Recommended attributes excluded
excludeFlag
excludeFlag
The attribute values that support exclusion include headlines [h], recommendations [c], slideshows [f], special recommendations [a], scrolls [s], bold [h], pictures [p], and jumps [j]. If the item list does not display the document with the specified flag attribute, the label isexcludeFlag="c"
- Whether to list the flag of the document
showFlag
showFlag
Supported values aretrue|false
, default isfalse
. If you need to display the flag tag of the document in the document list, set toshowFlag=true
- Whether to display subcategory content
child
child
Supported attribute values arefalse|true
, default true. If you want to display only documents belonging to the current category and do not include documents that are subcategorized, you need to specifychild=false
- sort by
order
order
You can specify the sorting rules for document display, and support sorting by latest documentorder="id desc"
, the most views document sortingorder="views desc"
, custom sort by backgroundorder="sort desc"
, by default, sorted by custom, you don't need to fill in it. - Display quantity
limit
limit
You can specify the number of displays and paging them by the number, for examplelimit="10"
Only 10 items will be displayed.limit
When it is not a paging list, supportoffset
Mode, that is,
Separation mode, if you want to get 10 pieces of data from item 2, you can set it tolimit="2,10"
. - List Type
type
type
Supports listing by page, list, and related. The default value is list,type="list"
When the specified limit is displayed, only the specified number of limit is specified, iftype="page"
Resume laterpagination
To organize pagination display{% pagination pages with show="5" %}
.type
If the value of related, the like parameter is supported. like="keywords|relation", the like parameter is not required by default, it automatically obtains other documents closest to the current document. If like="keywords" is specified, the relevant document will be obtained based on the first keyword of the document. If like="relation" is specified, only relevant documents set by the background document editing interface will be displayed. - Search keywords
q
q
Only in list typetype="page"
When effective, you can specify the search content. If you need to search for content, you can use the parametersq
To display the title search content that specifies the keywords, such asq="seo"
The rendering result will only show the title containingseo
List of keywords. It can also not be specified if there is a URLq=关键词
The query parameter ofq
Keyword content and used for search. - Filter parameters
自定义
Filter parameters are only in list typetype="page"
When effective, filter parameters only need to be placed on the query parameters of the url. In the additional automatic document configuration, filterable fields are configured. You can complete the document parameter filtering by appending these fields to the query parameters of the url. If you set filtering in your document automaticallysex,默认值有 男,女,保密
, then you can pass the query parameter of urlsex=男
To search for document sex field is the content of the man's document. - 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. - Combined document ID
combineId
combineId
This is a special field, which is used to append a document to the list, such as a document that is "Beijing" and a combined document that is "Shanghai", you can use{{item.Title}}到{{combine.Title}}的旅游线路
, the title generation of "Tour route from Beijing to Shanghai" can be achieved, and the new link will also be combined. If the ID of Beijing is 1 and the ID of Shanghai is 2, the URL may be: "/tour/1/c-2.html". - Pre-combined document ID
combineFromId
combineFromId
This is a special field, which is used to attach a document to the list. For example, a document is "Beijing" and the pre-combined document is "Shanghai", you can use{{combine.Title}}到{{item.Title}}的旅游线路
, the title generation of "Tour route from Shanghai to Beijing" can be achieved, and the new link will also be combined. If the ID of Beijing is 1 and the ID of Shanghai is 2, the URL may be: "/tour/2/c-1.html". andcombineId
The order is reversed.
UsedcombineId
orcombineFromId
After that, available in the list{{combine.文档字段}}
To call the field content of the combined document. Under the combination document URL,{{combineArchive.文档字段}}
Can be used to call the field content of a combined document.
archives is an array object, so it needs to be usedfor
Loop to output
item is a variable in the for loop body. The available fields are:
- Document ID
Id
- Document title
Title
- Document SEO title
SeoTitle
- Document link
Link
- Document keywords
Keywords
- Document description
Description
- Document model ID
ModuleId
- Document Classification ID
CategoryId
- Document specification link
CanonicalUrl
- Document user ID
UserId
- Superior ID
ParentId
- price
Price
- in stock
Stock
- Document reading level
ReadLevel
- Original link to the document
OriginUrl
- Document view count
Views
- Document cover picture
Images
- First image of the document cover
Logo
- Document cover thumbnail
Thumb
- Number of document comments
CommentCount
- Document addition time
CreatedTime
Time stamp, need to use formatted timestamps as date format{{stampToDate(item.CreatedTime, "2006-01-02")}}
- Document update time
UpdatedTime
Time stamp, need to use formatted timestamps as date format{{stampToDate(item.UpdatedTime, "2006-01-02 15:04:05")}}
- Document Flag
Flag
Display the flag attribute of the document. When querying the list, specifyshowFlag=true
- Document tags
- Other field parameters for document model settings
Code Example
{# list 列表展示 #} <div> {% archiveList archives with type="list" limit="10" %} {% for item in archives %} <li>
{# 如需判断当前是否是循环中的第一条,可以这么写: #} {% if forloop.Counter == 1 %}这是第一条{% endif %} {# 比如需要给第一条添加额外class="active",可以这么写: #} <a class="{% if forloop.Counter == 1 %}active{% endif %}" href="{{item.Link}}">{{item.Title}}</a> <span>当前第{{ forloop.Counter }}篇,剩余{{ forloop.Revcounter}}篇</span> <span>文档ID:{{item.Id}}</span> <span>上级ID:{{item.ParentId}}</span> <span>文档标题:{{item.Title}}</span> <span>文档链接:{{item.Link}}</span> <span>文档关键词:{{item.Keywords}}</span> <span>文档描述:{{item.Description}}</span> <span>文档分类ID:{{item.CategoryId}}</span> <span>文档浏览量:{{item.Views}}</span> <span>文档的Flag属性:{{item.Flag}}</span> <span>文档发布日期:{{stampToDate(item.CreatedTime, "2006-01-02")}}</span> <span>文档发布月日:{{stampToDate(item.CreatedTime, "01-02")}}</span> <span>文档发布时间:{{stampToDate(item.CreatedTime, "15:04:05")}}</span> <span>文档发布时分:{{stampToDate(item.CreatedTime, "15:04")}}</span> <span>文档发布日期时间:{{stampToDate(item.CreatedTime, "2006-01-02 15:04:05")}}</span> <div>封面首图<img src="{{item.Logo}}" alt="{{item.Title}}" /></div> <div>封面缩略图<img src="{{item.Thumb}}" alt="{{item.Title}}" /></div> 封面组图图片 <ul> {% for inner in item.Images %} <li> <img src="{{inner}}" alt="{{item.Title}}" /> </li> {% endfor %} </ul> 文档标签: {% tagList tags with itemId=item.Id limit="10" %} {% for item in tags %} <a href="{{item.Link}}">{{item.Title}}</a> {% endfor %} {% endtagList %} 文档额外字段 {% archiveParams params with id=item.Id %} <div> {% for item in params %} <div> <span>{{item.Name}}:</span> <span>{{item.Value}}</span> </div> {% endfor %} </div> {% endarchiveParams %} </li> {% empty %} <li> 该列表没有任何内容 </li> {% endfor %} {% endarchiveList %} </div>
列表展示文档
{# list 列表展示 #}
<div>
{% archiveList archives with type="list" categoryId="1" 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>
Get the following documents of the current document
Get the lower document through parentId, which is available on the document details page
{# 获取当前文档的下级文档 #}
{# 先获取当前文档的ID #}
{% archiveDetail archiveId with name="Id" %}
<div>
{# 再通过 指定 parentId 获取下级文档 #}
{% archiveList archives with type="list" parentId=archiveId 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>
展示相关文档
{# related 相关文档列表展示 #}
<div>
{% archiveList archives with type="related" 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 display document
{# page 分页列表展示 #}
<div>
{% archiveList archives with 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>
Search document page display
The default path to search and receive is:/search
Search form sample code:
<form method="get" action="/search">
<div>
<input type="text" name="q" placeholder="请输入搜索关键词" value="{{urlParams.q}}">
<button type="submit">搜索</button>
</div>
</form>
Note: The q here can be not specified, but dynamically obtained through the query parameters of the browser's url, such as:https://www.kandaoni.com/search?q=seo
{# page 搜索指定关键词分页列表展示 #}
<div>
{% archiveList archives with type="page" q="seo" 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
- Display documents under the category in a loop. As shown in the picture:
Call code example (the code does not contain css style control)
{% categoryList categories with moduleId="1" parentId="0" %}
<div>
{% for item in categories %}
<div>
<h3><a href="{{ item.Link }}">{{item.Title}}</a></h3>
<ul>
{% archiveList archives with type="list" categoryId=item.Id limit="6" %}
{% for archive in archives %}
<li>
<a href="{{archive.Link}}">
<h5>{{archive.Title}}</h5>
<div>{{archive.Description}}</div>
<div>
<span>{{stampToDate(archive.CreatedTime, "2006-01-02")}}</span>
<span>{{archive.Views}} 阅读</span>
</div>
</a>
{% if archive.Thumb %}
<a href="{{archive.Link}}">
<img alt="{{archive.Title}}" src="{{archive.Thumb}}">
</a>
{% endif %}
</li>
{% empty %}
<li>
该列表没有任何内容
</li>
{% endfor %}
{% endarchiveList %}
</ul>
</div>
{% endfor %}
</div>
{% endcategoryList %}
- Displays the lower-level classification of the classification in a loop multiple categories, and if there is no lower-level classification, the document of the classification is displayed. As shown in the picture:
Call code example (the code does not contain css style control)
<div>
{% categoryList productCategories with moduleId="2" parentId="0" %}
{% for item in productCategories %}
<a href="{{item.Link}}">{{item.Title}}</a>
<ul class="ind-pro-nav-ul">
{% if item.HasChildren %}
{% categoryList subCategories with parentId=item.Id %}
{% for inner in subCategories %}
<li><a href="{{inner.Link}}" title="">{{inner.Title}}</a></li>
{% endfor %}
{% endcategoryList %}
{% else %}
{% archiveList products with type="list" categoryId=item.Id limit="8" %}
{% for inner in products %}
<li><a href="{{inner.Link}}" title="">{{inner.Title}}</a></li>
{% endfor %}
{% endarchiveList %}
{% endif %}
</ul>
{% endfor %}
{% endcategoryList %}
</div>