How does AnQiCMS display the list of related documents, and what is its logic?

The core mechanism of the related document list in AnQiCMS

AnQiCMS through its powerful template tag system, especiallyarchiveListTags, which implement the display of related documents. This tag itself is a universal tool for calling various document lists, but when we want it to display "related" content, we only need to specifytype="related"this parameter.

ThisarchiveListLabels are typically used on document detail pages, and they intelligently or on-demand filter out other related documents based on the information of the current document.

Intelligent recognition logic for related documents

AnQiCMS determines which documents are 'relevant' using various logic, which allows us to choose the most suitable recommendation method according to our actual operational needs:

  1. Based on classification and proximity (default logic)When we arearchiveListsetting in the labeltype="related"When, if no other more specific conditions are specified, AnQiCMS will default to a straightforward association method: it will look for items associated with the current documentbelonging to the same categoryThe other documents. Among these documents in the same category, the system tends to recommend those that were published earlier or have a higher document ID.NearbyThe document. This method ensures the consistency of the context of recommended content, making it easier for users to find other in-depth content under the same topic when reading articles on a certain topic.

  2. Keyword-driven association(like="keywords")In addition to classification, AnQiCMS also allows us to utilize theKeywordsCome up with more intelligent recommendations for related content.When we set keywords for the document (which can be manually entered or selected from the keyword library in the document editing interface), the system can use these tags for matching.archiveListtags inlike="keywords"This parameter, AnQiCMS will identify the first keyword of the current document and use it as a basis to find other documents that contain this keyword.This method is very useful in scenarios where content is interlaced and categorized insufficiently, as it can recommend content across categories.

  3. Strongly related (manually selected by humans,like="relation")In certain specific situations, we may need to exercise more precise manual control over the relevant documents.For example, you would like to display a specific case study below the product page, or recommend a specific technical article at the bottom of a service introduction page.AnQiCMS provides the function to manually set "related documents" in the document editing interface.like="relation"This parameter,archiveListTags will only display those that weExplicitly specified in the backgroundThe document. This method gives operators a high degree of freedom, enabling precise content recommendations based on content strategy.

How to call and display in the template

Understood the logic behind, we can use it flexibly in the template. Here are some common calling examples:

An basic, displaying related documents.archiveListThe label usually would be like this:

{# 显示与当前文档同分类且临近的10篇相关文档 #}
<div class="related-docs">
    <h3>相关推荐</h3>
    <ul>
    {% archiveList archives with type="related" limit="10" %}
        {% for item in archives %}
        <li>
            <a href="{{item.Link}}" title="{{item.Title}}">
                {% if item.Thumb %}<img src="{{item.Thumb}}" alt="{{item.Title}}">{% endif %}
                <h4>{{item.Title}}</h4>
                <p>{{item.Description|truncatechars:80}}</p>
                <span>发布于:{{stampToDate(item.CreatedTime, "2006-01-02")}}</span>
            </a>
        </li>
        {% empty %}
        <li>暂无相关文档。</li>
        {% endfor %}
    {% endarchiveList %}
    </ul>
</div>

If we need to match more broadly based on keywords, we can modify it like this:

{# 基于当前文档关键词,显示10篇相关文档 #}
<div class="related-by-keywords">
    <h3>基于关键词的推荐</h3>
    <ul>
    {% archiveList archives with type="related" like="keywords" limit="10" %}
        {% for item in archives %}
        <li>
            <a href="{{item.Link}}" title="{{item.Title}}">
                <h4>{{item.Title}}</h4>
                <span>{{stampToDate(item.CreatedTime, "2006-01-02")}}</span>
            </a>
        </li>
        {% empty %}
        <li>暂无基于关键词的相关文档。</li>
        {% endfor %}
    {% endarchiveList %}
    </ul>
</div>

And for those scenarios that require refined manual configuration in the background, we can use:

{# 显示后台手动关联的文档 #}
<div class="related-by-manual">
    <h3>运营精选推荐</h3>
    <ul>
    {% archiveList archives with type="related" like="relation" limit="10" %}
        {% for item in archives %}
        <li>
            <a href="{{item.Link}}" title="{{item.Title}}">
                <h4>{{item.Title}}</h4>
                <p>{{item.Description|truncatechars:100}}</p>
            </a>
        </li>
        {% empty %}
        <li>暂无人工精选推荐文档。</li>
        {% endfor %}
    {% endarchiveList %}
    </ul>
</div>

In these loops,itemvariables provide a rich set of fields, such asId/Title(Title),Link(Link),Description(description),Thumb[Thumbnail],CreatedTimeThe creation time, etc., we can freely call according to the design requirements.

Summary

AnQiCMS througharchiveListTags and theirtype="related"


Common Questions (FAQ)

  1. Question: Why does my related document list always fail to display or show very few items? Answer:This usually has several reasons. First, please check if there are enough other documents in the category of the current document; second, if you have usedlike="keywords"Please confirm whether the current document has set keywords, and whether other documents also contain these keywords. If usedlike="relation"Then, make sure that other documents have been manually associated when editing documents in the background. In addition,limitThe parameter will also limit the number of displayed items. If the setting is too small, only a few articles may be displayed.

  2. 问:Can I use multiple related document recommendation logic on the same page? Answer:Yes, you can. AlthougharchiveListTagslikeonly one parameter can be selected at a time (for examplelike="keywords"orlike="relation"),but you can call it multiple times in the same document detail pagearchiveListlabel, each time using a different onelikeParameters, and are laid out on the page as different recommendation modules, such as "You may also like (based on category)"、"Hot keywords recommendation" or "Editor's choice" and so on.

  3. 问:The recommended logic for related documents, what does "closeness" specifically mean? Is it based on ID or publish time? Answer: