Document list tags

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 IDmoduleId
    moduleIdYou can get a list of documents for a specified document model, such asmoduleId="1"Get a list of documents for the article model.
  • Classification IDcategoryId
    categoryIdYou 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 specifiedcategoryIdIt 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 IDexcludeCategoryId
    excludeCategoryIdDocuments with specified categories can be excluded, such asexcludeCategoryId="1"Exclude documents with document classification ID 1. Multiple classification IDs are available, separated
  • Author IDuserId
    userIdYou 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 IDparentId
    parentIdYou can obtain documents from the specified superior, such asparentId="1"Get the document with the superior ID of 1.
  • Recommended attributesflag
    flagSupported 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 excludedexcludeFlag
    excludeFlagThe 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 documentshowFlag
    showFlagSupported 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 contentchild
    childSupported 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 byorder
    orderYou 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 quantitylimit
    limitYou can specify the number of displays and paging them by the number, for examplelimit="10"Only 10 items will be displayed.limitWhen it is not a paging list, supportoffsetMode, that is,Separation mode, if you want to get 10 pieces of data from item 2, you can set it tolimit="2,10".
  • List Typetype
    typeSupports 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 laterpaginationTo organize pagination display{% pagination pages with show="5" %}.typeIf 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 keywordsq
    qOnly in list typetype="page"When effective, you can specify the search content. If you need to search for content, you can use the parametersqTo display the title search content that specifies the keywords, such asq="seo"The rendering result will only show the title containingseoList of keywords. It can also not be specified if there is a URLq=关键词The query parameter ofqKeyword 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 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.
  • Combined document IDcombineId
    combineIdThis 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 IDcombineFromId
    combineFromIdThis 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". andcombineIdThe order is reversed.

UsedcombineIdorcombineFromIdAfter 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 usedforLoop to output

item is a variable in the for loop body. The available fields are:

  • Document IDId
  • Document titleTitle
  • Document SEO titleSeoTitle
  • Document linkLink
  • Document keywordsKeywords
  • Document descriptionDescription
  • Document model IDModuleId
  • Document Classification IDCategoryId
  • Document specification linkCanonicalUrl
  • Document user IDUserId
  • Superior IDParentId
  • pricePrice
  • in stockStock
  • Document reading levelReadLevel
  • Original link to the documentOriginUrl
  • Document view countViews
  • Document cover pictureImages
  • First image of the document coverLogo
  • Document cover thumbnailThumb
  • Number of document commentsCommentCount
  • Document addition timeCreatedTimeTime stamp, need to use formatted timestamps as date format{{stampToDate(item.CreatedTime, "2006-01-02")}}
  • Document update timeUpdatedTimeTime stamp, need to use formatted timestamps as date format{{stampToDate(item.UpdatedTime, "2006-01-02 15:04:05")}}
  • Document FlagFlagDisplay 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

  1. 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 %}
  1. 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>