How to use the `type=related` mode in the AnQiCMS document list interface to get related articles?

Calendar 👁️ 80

In website content operation, providing users with relevant article recommendations is an important strategy to enhance user experience, extend visit duration, and optimize content discovery. The document list interface of AnqiCMS is (archive/listProvided a very convenient feature, by settingtype=relatedparameters, you can easily achieve this goal.

Understandingtype=relatedmode

After a user finishes browsing a document (article, product, etc.), they usually hope to find more resources that are thematically similar and complementary to the current content. AnqiCMS'sarchive/listThe interface is designed for this. It allows you to request a list of other related documents from the system using a simple parameter.

The calling address of this function is:{域名地址}/api/archive/list

The request method is:GET

It is based on the coordination of the following parameters:

  1. type=relatedThis is the most critical parameter, it clearly tells the AnqiCMS interface that you expect to get recommended content related to a specific document, rather than ordinary list pagination or the entire list.
  2. id:Whentypeis set torelatedat that time, thisidThe parameter isnecessaryit specifies the one you want to get "related articles" ofthe ID of the current document. AnqiCMS will match other related content based on this ID intelligently.
  3. moduleIdIt is not required, but it is strongly recommended that you specify. If your website has multiple document models (such as article models, product models, etc.), clearlymoduleIdEnsure that AnqiCMS only searches for related articles within the model of the current document, avoiding recommendations of documents across models that may not be relevant.
  4. categoryId: It is also an optional parameter, but it is very helpful in enhancing relevance. By specifying the current document'scategoryIdYou can limit the search range of related articles to the same category, which usually provides more accurate recommendations.
  5. limit: Used to control the number of relevant articles returned, for example, setlimit=5The interface will return up to 5 related articles.
  6. order: You can use this parameter to sort the related articles. For example,order=views descCan retrieve the related articles with the highest view count under the current document category, ororder=created_time descto display the latest released related articles.

How to get the practical steps of related articles

Assuming you are developing an article detail page, you need to recommend 5 articles related to the current article at the bottom of this page.

Step 1: Get the ID of the current article

First, you need to know the ID of the article the current user is browsing. This ID is usually obtained when you through the interface to get the article details. For example, if the ID of the current article isarchive/detailis123.

The second step: Build the API request

Next, you can construct a request forarchive/lista GET request to the interface with the necessary parameters.

A typical request URL might look like this:

GET {域名地址}/api/archive/list?id=123&type=related&moduleId=1&categoryId=45&limit=5&order=views%20desc

  • id=123: The current article's ID is 123.
  • type=related: Specify to get related articles.
  • moduleId=1: The current article belongs to the article model with ID 1.
  • categoryId=45: Assuming the current article belongs to category ID 45. This helps to limit the recommended articles to the same category.
  • limit=5: Limit to returning only 5 related articles.
  • order=views%20descSort by views from high to low, recommend popular related articles.

Step 3: Process the returned data

AnqiCMS will return a JSON formatted data, whichdataThe field is an array that contains detailed information about related articles, for example:

{
  "code": 0,
  "data": [
    {
      "id": 124,
      "title": "相关文章标题一",
      "url_token": "related-article-one",
      "description": "这是相关文章一的简介...",
      "logo": "https://...",
      "link": "https://yourdomain.com/article/124.html"
    },
    {
      "id": 125,
      "title": "相关文章标题二",
      "url_token": "related-article-two",
      "description": "这是相关文章二的简介...",
      "logo": "https://...",
      "link": "https://yourdomain.com/article/125.html"
    }
    // ... 更多相关文章
  ],
  "msg": ""
}

You can traversedataArray, extract the title, link, thumbnail information of each article, and display it on the page.

optimize and **practice

  • Improve relevance accuracy:AnqiCMS will judge the relevance of the current article based on the classification, keywords and other information. Therefore, be sure tofill in the classification and keywords accuratelyThis will directly affecttype=relatedThe recommended effect of the model.
  • Control the number of displayed items: The number of relevant articles on the page should not be too many, usually 5-10 articles are a suitable range, which can be achieved throughlimitParameters for control. Too many recommendations may distract the user's attention.
  • Diversified sorting: Besides the default sorting, try usingorderParameters, such as sorting byviews desc(Browsing views in descending order) Recommend popular articles or sort bycreated_time desc(Published time in descending order) Recommend the latest articles to increase the diversity of recommendations.
  • Caching mechanism: For frequently visited article pages, the data of related article lists can be considered to be cached on the front-end or server-side to reduce API requests during each page load, thereby improving website performance.

By mastering the use oftype=relatedPattern, you can bring stronger internal link structure and better user browsing experience to websites driven by AnqiCMS, making your content more discoverable and usable.


Frequently Asked Questions (FAQ)

Q1: Why did I set uptype=relatedBut the interface returnsdataThe array is empty?A1: There are several reasons why an empty array is returned. First, please check if you have correctly passed the parameters of the current article'sidThis istype=relatedthe unique basis for pattern relevance matching. IfidInvalid or missing, the interface will not work. Secondly, AnqiCMS will try to match according to the classification, keywords and other information of the article. If the current article lacks these related information, or there are not enough relevant articles in the database to recommend, it may also lead to an empty list being returned.You can try to add more relevant tags and keywords to the article and ensure that there is enough other content associated with it.

Q2:type=relatedHow is the relevance of articles judged? Can I customize the relevance matching algorithm?A2: AnqiCMS internally usually matches based on common categories, tags, keywords, and other metadata of articles to intelligently identify related content.This is a built-in logic, designed to provide out-of-the-box related recommendation features.Currently, AnqiCMS's API interface does not provide an option to directly customize the relevance matching algorithm.But you can indirectly affect and optimize the recommendation effect of related articles by carefully planning the classification system of the articles, accurately setting the tags and keywords, and adding more contextual information to the content of the articles themselves.

Q3: If I only want to retrieve relevant articles in a specific category, what should I do?A3: If you want to limit the scope of related articles to a specific category, in addition to settingtype=relatedand the current article'sidyou should also providecategoryIdThe parameter should be set to the category ID of the current article. For example: `id=123&type=related&categoryId=

Related articles

How to build pagination navigation for AnQiCMS document list on the front-end page (using `page` and `total` parameters)?

When displaying a large number of documents on the website frontend, pagination navigation is a key feature for improving user experience and managing data loading efficiency.AnQiCMS (AnQiCMS) provides a powerful and flexible API interface, allowing you to easily implement pagination of document lists on the front end.This article will introduce in detail how to use the `page` and `total` parameters in the `archive/list` interface to build a fully functional pagination navigation.--- ### Understanding the core of AnQi CMS pagination mechanism To build pagination navigation for the document list

2025-11-09

In the AnQiCMS document list, what do the `images`, `logo`, and `thumb` fields represent, and how should they be used?

When using AnQi CMS to manage website content, we often encounter scenarios involving image upload and display.In the data structure of documents (articles, products, etc.), categories, and even single pages, the `images`, `logo`, and `thumb` fields play different roles. They work together to support the effective presentation and performance optimization of the website's visual content.Understanding their specific purposes can help us better plan content and optimize the user experience.### `images` : multi-image display and rich content `images`

2025-11-09

How to handle the `extra` field returned by the `archive/list` interface to obtain custom field information?

When using AnQi CMS for website content management, we often need to display more personalized data beyond the usual information such as title, summary, thumbnail, etc.This additional information, such as the author of the article, the model of the product, the release location, etc., is achieved through the powerful custom field function of Anqi CMS.How can we elegantly extract and utilize these custom fields when we obtain the document list through the `archive/list` interface on the front end?The answer is hidden in the `extra` field of the returned data

2025-11-09

How to use the `q` parameter to perform keyword search in the AnQiCMS document list and realize the in-site search function?

In the daily operation of a website, providing users with an efficient and convenient in-site search function is a key factor in improving user experience and guiding content discovery.For those of us using AnQiCMS to manage website content, it is not difficult to achieve this function.AnQi CMS provides a very practical parameter——`q`, which allows us to easily search for keywords in the document list.### Start the in-site search journey: Understanding the `q` parameter In the AnQiCMS document list interface (/api/archive/list), `q`

2025-11-09

Is the `created_time` and `updated_time` returned by the AnQiCMS document list a Unix timestamp, and how do I convert it to a readable date?

When using AnQiCMS, we often retrieve detailed information or lists of documents or other content from the API interface.In these returned data, `created_time` (creation time) and `updated_time` (update time) are two very critical fields.Many users may be curious, what are these values that look like a string of numbers?They are actually standard Unix timestamps. ### Understanding Unix Timestamps Unix timestamp, also known as Posix time

2025-11-09

How to determine the visibility or review status of the document from the `archive/list` interface?

In AnQi CMS, one of the core aspects of content management is the control of document status, which directly relates to the visibility and review process of website content.When you retrieve the document list through the `archive/list` interface, the `status` field in the returned data assumes this critical responsibility.Understanding the meaning of this field can help you manage website content more efficiently and ensure that information is presented correctly to visitors.### `status` field

2025-11-09

How to combine the filtering conditions obtained from `archiveFilters.md` and apply them to the custom filtering parameters of `archive/list`?

In Anqi CMS, efficiently managing and displaying website content is the key to improving user experience.When the amount of content grows, providing flexible filtering functions is particularly important to help visitors quickly find the information they need.The AQ CMS provides powerful API interface support, by cleverly combining the filtering conditions obtained from the `archive/filters` interface and applying them to the custom filtering parameters of the `archive/list` interface, we can build extremely practical content filtering functionality.###

2025-11-09

When `archive/list` returns `code` as `-1`, what error messages will the `msg` field provide?

When using Anqi CMS for website content management, we often deal with various API interfaces, among which the `archive/list` interface is the core for obtaining the document list.You may encounter the situation where the interface returns `code` as `-1` during use.At this moment, understanding the information provided by the `msg` field is particularly important, as it helps us quickly locate the source of the problem.

2025-11-09