Related Document Tags

Description: Get relevant documents for the current document. The logic of the relevant documents is: obtain adjacent documents of the same category based on the document id of the current document. Therefore, this tag can only be used on the document details page.

How to use:{% archiveList 变量名称 with type="related" limit="10" %}If you define a variable as archives{% archiveList archives with type="related" limit="10" %}...{% endarchiveList %}

typeIf the value of related, the order parameter is not supported.

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.


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 linkLink
  • Document keywordsKeywords
  • Document descriptionDescription
  • Document Classification IDCategoryId
  • 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 tags
  • Other field parameters for document model settings

Code Example

Get relevant document tags, which can only be used on the document details 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>