related document tag

Description: Get related documents of the current document. The logic of related documents is: obtain nearby documents of the same category based on the document id of the current document.Therefore, this tag can only be used on the document detail page.

Usage:{% archiveList 变量名称 with type="related" limit="10" %}If the variable is defined as archives{% archiveList archives with type="related" limit="10" %}...{% endarchiveList %}

typeThe value is related, the order parameter is not supported.

typeThe value is related, and supports the like parameter.like=“keywords|relation”,default no need for like parameter, it automatically retrieves the documents closest to the current document.If specified like="keywords", it will retrieve relevant documents based on the first keyword of the document.If specified like="relation", it will only display the related documents set in the background document editing interface.

archives is an array object, so it needs to be usedforloop to output

item is the variable within the for loop, the available fields are:

  • Document IDId
  • Document titleTitle
  • Document linkLink
  • Document keywordKeywords
  • Document descriptionDescription
  • Document Category IDCategoryId
  • Document ViewsViews
  • Document cover imageImages
  • Document cover first imageLogo
  • Document cover thumbnailThumb
  • Document comment countCommentCount
  • Document add timeCreatedTimeTimestamp, needs to be formatted as a date{{stampToDate(item.CreatedTime, "2006-01-02")}}
  • Document Update TimeUpdatedTimeTimestamp, needs to be formatted as a date{{stampToDate(item.UpdatedTime, "2006-01-02 15:04:05")}}
  • Document Tag
  • Other field parameters set for document model

Code example

Get related document tags, can only be used on the document detail page.

{# 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>