Related document tags

Description: Get related documents of the current document.The logic of the related documents is: Get the adjacent documents of the same category according to the current document's document id.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' does not support the 'order' parameter.

typeThe value is related, support like parameter.like="keywords|relation", the like parameter is not required by default, it automatically retrieves the other documents closest to the current document.If like="keywords" is specified, it will retrieve relevant documents based on the first keyword of the document.If like=“relation” is specified, only the documents related to the backend document editing interface settings will be displayed.

'archives' is an array object, so it needs to be usedforin a loop to output

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

  • Document IDId
  • Document TitleTitle
  • Document LinkLink
  • Document KeywordsKeywords
  • Document DescriptionDescription
  • Document Category IDCategoryId
  • Document ViewsViews
  • Document Cover ImageImages
  • Document Cover First ImageLogo
  • Document cover thumbnailThumb
  • Document comment countCommentCount
  • Document added timeCreatedTimeTimestamp, needs to format the timestamp to date format{{stampToDate(item.CreatedTime, "2006-01-02")}}
  • Document update timeUpdatedTimeTimestamp, needs to format the timestamp to date format{{stampToDate(item.UpdatedTime, "2006-01-02 15:04:05")}}
  • Document tag
  • Document model settings for other field parameters

Code example

Get related document tags, which 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>