How to display the list of related documents in AnQiCMS template?

Calendar 👁️ 51

As a website operator who has been deeply involved in the CMS of AnQi for many years, I know that effectively guiding users to discover more interesting content is crucial for enhancing user stickiness and the depth of website visits.Among them, the 'related document list' is undoubtedly one of the core functions to achieve this goal.It not only helps users conveniently explore more related topics, but also has a positive impact on the internal link structure and SEO optimization of the website.

AnQi CMS provides a powerful and flexible tag system in template design, making it a relatively direct operation to display related document lists on the document detail page. By utilizing built-inarchiveListLabels, and with specific parameters, we can easily implement this feature.

Understand the "related documents" mechanism of Anqi CMS

AnQi CMS defines "related documents" as content that is associated with the document currently being viewed in some aspects.This association can be based on the classification of documents, keywords, or manual association in the background.It is worth noting that the related document list is usually only applicable to the document detail page, as its logic revolves around the current document.The system will try to find documents with the same category or shared keywords based on the current document ID.

Core tags:archiveListwithtype="related"

In the Anqi CMS template system, the main tag used to obtain the list of related documents isarchiveList. This tag is very versatile, not only can it be used to display a list of documents or pagination lists, but by settingtype="related"parameters, it can intelligently extract documents related to the current document.

archiveListThe label is set astype="related"At that time, it also supports a keylikeparameter, used to further refine the matching logic of the relevant document.

  • Default association: When not specifiedlikeWhen a parameter is specified, the system will automatically retrieve the nearest documents in the same category based on the current document's ID. This is a natural association based on category and time/ID sequence.
  • Based on keyword association (like="keywords"): If you want the recommendation of related documents to be more focused on the similarity of content topics, you can setlike="keywords".In this mode, the system extracts the first keyword of the current document and uses it as a basis to search for other documents containing the same keyword as relevant content.This is very useful for a website with a clear content theme.
  • Based on backend manual association (like="relation")For some scenarios that require fine-grained control of related recommendations, such as product association recommendations on e-commerce websites, operators may want to manually specify which documents are related. This can be done by setting the "related documents" field when editing documents in the background and using the template.like="relation"Ensure that only these explicitly specified documents are displayed.

excepttypeandlikeOutside the parameters,archiveListTags also supportlimit(Control the number of displayed items),moduleId(Specify the content model, such as the article model or product model),siteIdParameters such as "specified site under a multi-site environment" to meet more detailed call requirements.

Actual operation: How to display a list of related documents in the template.

We need to add the corresponding tag code in the template file (for example) to display the list of related documents in the AnQi CMS template.{模型table}/detail.htmlorarchive/detail.html)

Here is a general code example that demonstrates how to retrieve and display the default list of related documents:

<div class="related-articles-section">
    <h3>相关推荐</h3>
    <ul>
        {% archiveList archives with type="related" limit="5" %}
            {% for item in archives %}
            <li>
                <a href="{{item.Link}}">
                    <img src="{{item.Thumb}}" alt="{{item.Title}}">
                    <h4>{{item.Title}}</h4>
                    <span>{{stampToDate(item.CreatedTime, "2006-01-02")}}</span>
                </a>
            </li>
            {% empty %}
            <li>
                暂无相关文档。
            </li>
            {% endfor %}
        {% endarchiveList %}
    </ul>
</div>

In this example:

  • archiveList archives with type="related" limit="5"We calledarchiveListLabel, set its type torelatedLimiting to display up to 5 related documents. The result set is namedarchives.
  • {% for item in archives %}:Traversearchivesarray,itemThe variable represents each related document.
  • {{item.Link}}: Output the link of the related document.
  • {{item.Thumb}}: Output the thumbnail of the related document.
  • {{item.Title}}Output the title of the relevant document.
  • {{stampToDate(item.CreatedTime, "2006-01-02")}}Format the creation time of the document.
  • {% empty %}...{% endfor %}If:archivesIf empty (i.e., no relevant document is found), then display the prompt 'No relevant document available'.

If you need to associate based on keywords, you can modify it in this wayarchiveListTags:

<div class="related-articles-by-keywords">
    <h3>相关主题文档</h3>
    <ul>
        {% archiveList archives with type="related" like="keywords" limit="5" %}
            {% for item in archives %}
            <li>
                <a href="{{item.Link}}">
                    <h4>{{item.Title}}</h4>
                </a>
            </li>
            {% endfor %}
        {% endarchiveList %}
    </ul>
</div>

If you want to display the relevant documents manually specified by the background, then uselike="relation":

<div class="explicitly-related-documents">
    <h3>运营推荐文档</h3>
    <ul>
        {% archiveList archives with type="related" like="relation" limit="5" %}
            {% for item in archives %}
            <li>
                <a href="{{item.Link}}">
                    <h4>{{item.Title}}</h4>
                </a>
            </li>
            {% endfor %}
        {% endarchiveList %}
    </ul>
</div>

Optimization and considerations for displaying relevant content

In the operation, simply displaying relevant documents is not enough, we also need to consider how to optimize their display effect to better serve users and the goals of the website.

  • Enhance relevanceSystem-provided features: excludinglikeParameters, can also be optimized through document classification and keyword settings to ensure the accuracy and relevance of the content.For some core content, it is considered to manually specify relevant documents in the background to provide more accurate recommendations.
  • User experience and interface designThe layout and style design of the related document list is crucial.Consider displaying a thumbnail, a brief description, and the publish time for each document to help users quickly determine if they are interested.Ensure the list is easy to read and does not distract the user from the main content.
  • Loading performance:limitParameters can effectively control the number of related documents, avoiding loading too much data at once, thereby optimizing page loading speed. For high-traffic websites, it is crucial to setlimitvital.
  • Placement locationThe related document list is usually placed at the end of the document content or in the sidebar, so that it can cater to the user's interest after reading the main content without disrupting their reading flow.

By using the above method, we can take advantage of the powerful template tag system of Anqie CMS to create a comprehensive and user-friendly document recommendation module for the website, thereby enhancing the value of the website's content and user experience.


Frequently Asked Questions (FAQ)

Why is my document detail page not displaying any related documents?

There may be several reasons for this. First, please confirm whether you have used it on the document detail page.archiveListtags and settype="related"Check if there are other documents under the category of the current document, if the number of documents is too few, the system may not be able to find enough related content. If you have usedlike="keywords"Please ensure that the current document has at least one keyword and that other documents also share the same keyword. If you have usedlike="relation"Check whether the current document is manually associated with other documents in the background. Finally,limitParameter setting too low may also cause no content to be displayed, try setting it higher.

How to display the list of related documents based on shared tags (Tag)?

Of Security CMSarchiveListThe tag is intype="related"The mode does not directly support association through Tag. However, you can achieve a similar effect by the following two methods:

  1. Indirect method: using keywordsWhen setting tags for documents in the background, you can also use some tags as keywords for the documents, then use{% archiveList archives with type="related" like="keywords" limit="N" %}tags, the system will match based on the keywords.
  2. combined tags:tagList+archiveListYou can first usetagListto get all the tags of the current document, then iterate over these tags, and use them for each tagtagDataListTag to display the documents under this tag. This method will display multiple lists of related documents grouped by tag, and may require some additional logic to deduplicate or merge.

Can I customize the matching rules for 'related documents', not just rely on categories or keywords?

archiveListTag provided.type="related"cooperatelike="keywords"orlike="relation"The parameters have already provided a more flexible matching rule.like="relation"Allow you to manually specify related documents in the background, providing the highest degree of customization. If these built-in options still cannot meet your special needs, such as complex matching based on specific custom fields in the document content model, it may require in-depth secondary development of the Anqi CMS backend logic, or in the template layer through more complex logic (such as first obtaining the value of a certain custom field of the current document, and then using it to ...archiveListofqThe parameter searches for the matching document, which will increase the complexity of the front-end template). Usually, keywords and manual association can meet most operational needs.

Related articles

How to call the previous and next document links in AnQiCMS template?

As a senior CMS website operation personnel in an enterprise, I am well aware of the importance of content navigation for user experience and SEO.On a day when the content of the website is becoming richer and richer, how to guide users to smoothly browse related content is a key factor in enhancing user stickiness and reducing the bounce rate.Today, we will delve into how to cleverly call the links of the previous and next documents in the AnQiCMS template to optimize your website's content structure and user path.### Enhancing User Experience and SEO: Navigation of Previous and Next Documents in AnQiCMS Templates In the Content Management System

2025-11-06

How to obtain document detail data and display content in AnQiCMS template?

As an experienced security CMS website operator, I know that it is crucial to efficiently and accurately obtain and present document detail data in terms of content display.A well-crafted detail page not only meets users' in-depth information needs, but also effectively enhances the website's stickiness and search engine performance through optimizing content structure and user experience.In Anqi CMS, taking advantage of its flexible Django template engine syntax, obtaining and displaying document detail data is a direct and powerful process.

2025-11-06

How to call the article or product category list in AnQiCMS template and implement multi-level nesting?

As a senior website operator at AnQiCMS, I fully understand that efficient content organization and presentation are crucial for user experience and SEO.Categorization list, especially multi-level nested categorization lists, can clearly present the hierarchical structure of the website's content, guide users to discover more interesting content, and also provide clear site structure information for search engines.This article will detail how to call the article or product category list in the AnQiCMS template and implement a multi-level nested display effect.

2025-11-06

How to get and display the navigation list and its sub-menu in AnQiCMS template?

## AnQiCMS Navigation List and Submenu Display in Templates As an experienced AnQiCMS website operations personnel, I am well aware of the importance of a clear and efficient website navigation for user experience and content access.AnQi CMS provides a powerful and flexible navigation list tag `navList` for template developers, making it easy to obtain and display the main navigation, footer navigation, and even more complex multi-level navigation structures with submenus on the website front-end.

2025-11-06

How to use the for loop in AnQiCMS template to traverse data and handle empty results with the empty tag?

## Master the data traversal and empty result handling in AnQiCMS templates: in-depth analysis of for loops and empty tags AnQiCMS, with its efficient and customizable features, has become the preferred content management system for many content operation teams and small and medium-sized enterprises.It is crucial for the flexibility of template language when building dynamic web pages.

2025-11-06

How to perform conditional judgments (if/elif/else) in Anqi CMS template?

As an experienced CMS website operation personnel, I am well aware that the flexibility of templates is crucial for efficient operation in daily content management.Especially conditional judgment allows us to intelligently control the display and hiding of content based on different data states and business logic, thereby providing users with a more accurate and personalized browsing experience.The Anqi CMS template engine has adopted the syntax style of Django, making the implementation of conditional judgments both powerful and easy to understand.### The basic structure of conditional judgment in AnQi CMS template Conditional judgment in the AnQi CMS template is mainly achieved through

2025-11-06

How to format timestamp output in AnQiCMS template?

As a professional familiar with Anqi CMS and proficient in content operation, I know that accuracy and beauty in website content display are crucial.A clear and easy-to-read timestamp that not only improves user experience but also reflects the standardization of data display.Below, I will give you a detailed introduction on how to format timestamp output in AnQiCMS template.

2025-11-06

What are the common functions of filters in AnQiCMS templates (such as truncation, replacement)?

In AnQi CMS template design, filters play a vital role.As an experienced website operator, I know that skillfully using these tools can greatly enhance the quality of content presentation and user experience.The Anqicms template engine has adopted Django's syntax, allowing content creators and template developers to conveniently process and format output data, achieving rich display effects without delving into the backend code.

2025-11-06