How to retrieve and display the document list related to the current document in AnQiCMS template?

Calendar 👁️ 52

As a website operator who deeply understands the operation of Anqi CMS, I am well aware of the core value of content strategy for user experience and website growth.High-quality content not only requires careful creation, but also needs to be intelligently organized and presented to ensure that readers can easily find more information that interests them.How to effectively display the list related to the current document on the article detail page is an important factor in enhancing user stickiness and page browsing depth.

Now, let's delve into how to implement this feature in the AnQiCMS template, by dynamically displaying relevant content to provide your readers with a seamless reading experience.

The related document list in AnQiCMS template: the key to enhance user experience

In AnQiCMS, displaying related document lists for the current document is an effective strategy to optimize the user's reading path and increase the exposure rate of the website content.After readers finish reading an article, if they can immediately see more highly related information, they will stay longer on the page, the page bounce rate will decrease, which is very beneficial for the overall data performance of the website and search engine optimization.

Understanding how AnQiCMS defines 'related' documents

AnQiCMS provides a flexible and intelligent mechanism when determining 'related' documents, which allows us to accurately present content according to actual operational needs.By default, the system will try to automatically associate other documents based on the current document's category and content similarity.This means that articles in the same category, or those that overlap in themes or keywords, are more likely to be identified as relevant content by the system.

In addition, AnQiCMS also allows us to control the association logic of related documents more finely.For example, we can specify that the matching of related documents should mainly be based on keywords, or completely rely on the manual association settings on the back-end.This multi-dimensional 'relevance' definition allows us to choose the most suitable display method based on content type and operational objectives.

Retrieve and display related documents in the template

In the AnQiCMS template system, retrieve and display the list of related documents to the current document, mainly depending on the powerfularchiveListThe tag is a core tool for content display, which can meet various content calling needs, including the call of 'related documents'.

It is worth noting that the invocation of the related document list usually occurs inDocument detail pageMiddle dot.This is because the concept of "relevant" is relative to a "current document", so only on the specific document detail page can the system accurately identify the context and retrieve the corresponding related content.

To invoke the related document, we need toarchiveListExplicitly specify in the tagtype="related"The parameter tells AnQiCMS what list is needed related to the current document.

The followingarchiveListis the key parameter used in the tag to control the behavior of related documents.

  • type="related": This is the core parameter to enable the related document list function and must be set.
  • limit: This parameter is used to control the number of displayed related documents. For example,limit="5"The maximum number of 5 related documents will be displayed. You can also uselimit="offset,count"the format, for examplelimit="2,5"indicating starting from the 2nd document, retrieve 5 documents.
  • likeThis parameter allows you to define the matching rules for related documents:
    • Not setlikeParameter (or leave blank): The system will automatically match the most closely related documents based on the category and content similarity of the current document. This is the most commonly used default behavior.
    • like="keywords": When you want related documents to mainly match based on the keywords of the current document.This requires your document to fill in accurate keywords in the background.The system will try to find other documents containing the same keywords.
    • like="relation": If you manually set the 'related documents' link in the document editing interface of the AnQiCMS backend, then this parameter will only display these manually associated documents.This provides the highest degree of manual control.

By combining these parameters, you can flexibly implement various document display logic in the front-end template.

Code practice: Display document list

Now, let's demonstrate how to retrieve and display related document lists in the document detail page template of AnQiCMS with a practical code example.

Suppose we are editing a nameddetail.htmlThe article detail page template, we hope to display up to 6 related articles below the article content, prioritizing thumbnails and publication dates.

{# 假设这里是当前文档的内容区域结束 #}
<div class="article-content">
    {# ... 当前文档的详细内容 ... #}
</div>

{# 相关文档列表区域 #}
<div class="related-articles-section">
    <h2>相关推荐</h2>
    <ul class="related-articles-list">
        {# 使用 archiveList 标签获取相关文档。type="related" 是关键,limit="6" 控制数量 #}
        {% archiveList archives with type="related" limit="6" %}
            {% for item in archives %}
            <li class="related-article-item">
                <a href="{{ item.Link }}" title="{{ item.Title }}">
                    {% if item.Thumb %}
                        {# 如果有缩略图,则显示 #}
                        <img src="{{ item.Thumb }}" alt="{{ item.Title }}" class="related-article-thumb">
                    {% else %}
                        {# 没有缩略图时,可以显示一个默认占位图,或者不显示图片 #}
                        <img src="/static/images/default-thumb.jpg" alt="暂无图片" class="related-article-thumb">
                    {% endif %}
                    <h3 class="related-article-title">{{ item.Title }}</h3>
                    <p class="related-article-description">{{ item.Description|truncatechars:80 }}</p> {# 截取描述,避免过长 #}
                    <span class="related-article-date">发布于:{{ stampToDate(item.CreatedTime, "2006-01-02") }}</span>
                </a>
            </li>
            {% empty %}
            {# 如果没有任何相关文档,可以显示一条提示信息 #}
            <li class="no-related-articles">
                暂无更多相关文章推荐。
            </li>
            {% endfor %}
        {% endarchiveList %}
    </ul>
</div>

In the above code:

  • {% archiveList archives with type="related" limit="6" %}This is the core call, which will retrieve up to 6 articles related to the current document and store them inarchivesthe variable.
  • {% for item in archives %}: We traversearchivesEach related article in the list, the data of each article can be found initemAccessed in the variable.
  • {{ item.Link }},{{ item.Title }},{{ item.Description }},{{ item.Thumb }}These areitemThe fields available in the object, representing the article link, title, description, and thumbnail.
  • {% if item.Thumb %}: Ensure that the article is displayed only when there is a thumbnail, otherwise a default image can be provided.
  • {{ item.Description|truncatechars:80 }}: Use a filter to truncate the description content to keep the page tidy.
  • {{ stampToDate(item.CreatedTime, "2006-01-02") }}UtilizestampToDateThe tag formats the article creation timestamp into a readable date.
  • {% empty %}This is a very practical loop control structure, whenarchivesWhen the list is empty (i.e., no related documents are found), it will displayemptyContent within the block to avoid blank pages on the page.

Optimize the display effect of the relevant documents

It is not enough to simply retrieve the data, as website operators, we should pay more attention to the presentation of the content.

  • Visual consistency: Make sure the style of the related document list is consistent with the overall design style of your website, avoiding a sense of abruptness.
  • Information refiningIn the list, the title and thumbnail are often the most attractive elements. Consider truncating the description text or only displaying brief information to keep the interface clean.
  • Click诱导Use clear titles and attractive thumbnails to encourage users to click and view more content.
  • Test and adjustAfter release, closely monitor the click-through rate and user behavior data of relevant documents. If the results are not good, you can try adjustinglimitthe number, or changelikeParameter settings, see which matching logic can best attract your readers.

By following these steps, you can flexibly and efficiently obtain and display the list related to the current document in the AnQiCMS template, thereby greatly enhancing the user's content discovery experience on the website.


Frequently Asked Questions (FAQ)

1. Why is the related document not displayed on my document detail page?

There may be several reasons for this. First, please make sure you have used the template correctly.{% archiveList archives with type="related" ... %}Label, and it is located on a document detail page because this label requires the context information of the current document.Next, check if there is truly "related" documents: if there are no other documents under the current document's category, or no related documents through keywords, manual association configuration, the list will naturally be empty.limitThe parameter was not set small enough, causing even relevant documents to not be displayed.

2. Besides automatic association, can I manually set relevant documents?

Of course you can.AnQiCMS provides a manual association feature.You can find the "related documents" setting item when editing each document in the background, and manually select other documents associated with the current document.archiveListlabel'slikethe parameter tolike="relation"These associated documents set manually by AnQiCMS will be displayed first. This gives you the greatest degree of control, ensuring that the most important or most

Related articles

How to display the link to the previous and next document in the AnQiCMS template?

As an experienced security CMS website operator, I am well aware of the importance of website content navigation for user experience and search engine optimization.Clear and convenient navigation not only guides users to delve into the website content, effectively extending their stay time, but also helps build a perfect internal link structure, enhancing the search engine's crawling efficiency and content weight.Today, we will discuss in detail how to flexibly display the previous and next document links of the current document in the AnQiCMS template.### Template Basics Review The template engine in AnQiCMS uses something similar to Django

2025-11-06

How to get the detailed information of the current document in AnQiCMS template (such as title, content, thumbnail)?

As an experienced AnQiCMS website operator, I am well aware of the importance of flexibly obtaining and displaying content in templates.AnQiCMS is a powerful template engine that makes content creation, editing, and publishing efficient and convenient.Today, we will delve into how to obtain detailed information about the current document in the AnQiCMS template, such as the title, content, and thumbnail, to help you better customize the front-end display of the website.

2025-11-06

How to filter and display the document list in AnQiCMS template according to categories, models, recommended attributes, etc.

As an experienced AnQiCMS website operations manager, I fully understand the importance of efficient content management and flexible display.In AnQiCMS, the filtering and display of document lists are indispensable functions for building dynamic websites.Whether it is to display the latest articles under a specific category, or to differentiate products and news according to the content model, or to highlight recommended content, AnQiCMS's powerful template tags can help us easily achieve these needs.

2025-11-06

How to display the detailed content of a specified single page in AnQiCMS template?

In AnQiCMS website operation, the Single Page (Page) feature is a very practical module, which allows us to create and manage static pages independent of dynamic content such as articles or products, such as "About Us", "Contact Information", or "Service Introduction" and so on.These pages usually contain relatively fixed and important information, which needs to be presented to visitors in a clear and direct manner.As a senior operator of AnQiCMS, I know how to effectively use the template mechanism to accurately control the display of these single pages to meet the diverse design and content needs.

2025-11-06

How to call custom document extra parameters (such as article author, product price) in AnQiCMS templates?

In the daily operation of AnQiCMS, we often need to add some personalized information to different types of content (such as articles, products), such as the specific author of the article, the detailed price of the product, the production date, etc.AnQiCMS is a powerful content model feature that allows us to flexibly define these custom fields and conveniently call them and display them in templates, thereby meeting the diverse content display needs.

2025-11-06

How to create a multi-condition filtering interface based on document parameters in the AnQiCMS template?

As an experienced security CMS website operator, I know that building an efficient, user-friendly content filtering interface is important for improving user experience and content discoverability.In AnQiCMS, with its flexible content model and powerful template tag system, we can easily create a multi-condition filtering interface based on document parameters.This not only helps readers quickly find the information they need, but also effectively improves the organization and SEO performance of the website content.### The Basics of Creating a Multi-Condition Filter Interface: Understanding Document Parameters In AnQiCMS

2025-11-06

How to display the Tag list or document list of a specified Tag in AnQiCMS template?

As an experienced CMS website operation personnel of an enterprise, I fully understand the core value of content tags in website content management and user navigation.High-quality tag strategies not only help readers quickly find the information they need, but also effectively improve the organization and SEO performance of website content.Next, I will elaborate on how to flexibly use tags in AnQiCMS templates to display tag lists or document lists under specific tags.### Understand the content tags in AnQiCMS In AnQiCMS, content tags (Tags) are a powerful content association tool

2025-11-06

How to integrate and display comment lists in AnQiCMS templates?

Effectively integrating and displaying the comment list in AnQi CMS is crucial for enhancing website user interaction, activating community atmosphere, and obtaining valuable user feedback.As an experienced CMS website operation personnel of an enterprise, I know that high-quality content cannot be separated from the active participation of users.The Anqi CMS provides powerful and flexible template tags, allowing us to easily implement this feature on the front end of the website.### Overview of Comment Functionality and Template File Organization AnQi CMS has built-in comment management functionality, allowing website administrators to review, reply to, and manage user comments

2025-11-06