How to efficiently extract and display the article summary (description field) from the AnQiCMS document list?

Calendar 👁️ 77

It is crucial to provide clear and attractive summaries for articles on the website in content management.This not only helps search engines better understand the content of the page, improve inclusion and ranking, but also quickly captures the attention of visitors on list pages, search result pages, or social sharing, guiding them to click and read the full content.AnQiCMS (AnQiCMS) provides various flexible ways to manage and access this content, including efficiently extracting and displaying article summaries (descriptionField`) is a common requirement in our daily operations.

AnQiCMS provides a set of intuitive and powerful API interfaces, making it very convenient to retrieve various data from the backend. We mainly use it for extracting article lists and their summaries.archive/listThis interface. The original intention of this interface design is to facilitate developers and operations personnel to obtain data of multiple articles, and the article summary field (description) Contains in the returned article object.

Efficient usearchive/listInterface extract summary

To get the article summary from the document list,archive/listThe interface is your preference. It is simple and direct in its calling method, throughGETthe method to send requests, and you can attach some parameters in the request to filter and control the returned data.

Firstly, you need to know the domain address of your AnQiCMS site. The general format of the API call address is:{域名地址}/api/archive/list. For example, if your website domain ishttps://en.anqicms.comThen, the interface address is:https://en.anqicms.com/api/archive/list.

When initiating a request, there are several key parameters to pay attention to that can help you accurately obtain the list of articles you need:

  • moduleId: This is a very important parameter, it specifies the document model you want to retrieve. For example, the ID of the conventional article model is usually1. If you want to get the product list or other custom model article summaries, you need to fill in the corresponding information according to the actual situationmoduleId.
  • categoryId: If you want to get the article summary of a specific category, you can use this parameter. You can enter a single category ID, or separate multiple category IDs with commas.
  • typeThis parameter controls the return mode of the list. When you need to display pagination, you should settypeis set topage. In this way, the interface will return the total number of articles at the same timetotalfield), convenient for you to build pagination navigation. If you just want to get a specified number of articles, the defaultlisttype is enough.
  • limit: Used to specify the number of articles returned. For example,limit=10Indicates fetching 10 articles. It also defines the number of articles per page when pagination is needed. It even supportsoffset,limitpatterns such aslimit=2,10Represents starting from the second item and retrieving 10 items.
  • page: Only whentypeis set topageis valid, used to specify which page of content you want to retrieve.

For example, if you want to get the summary of the latest 5 articles under the category with ID 10 of the article model, you can construct your API request in this way:

GET {域名地址}/api/archive/list?moduleId=1&categoryId=10&type=list&limit=5&order=created_time desc

After you send the request, if everything goes well, the interface will return a JSON-formatted data. In this JSON response,dataThe field is an array, each element of which represents a specific article information. The article summary we need is stored in each article object'sdescriptionin the field.

Return data example snippet (simplified):

{
  "code": 0,
  "data": [
    {
      "id": 1,
      "title": "关于AnqiCMS",
      "description": "安企内容管理系统(AnqiCMS),是一款使用 GoLang 开发的企业站内容管理系统,它部署简单,软件安全,界面优雅,小巧,执行速度飞快,使用 AnqiCMS 搭建的网站可以防止众多安全问题发生。",
      // ... 其他文章信息
    },
    {
      "id": 2,
      "title": "AnqiCMS使用帮助",
      "description": "anqicms常见问题汇总",
      // ... 其他文章信息
    }
  ],
  "msg": "",
  "total": 2
}

Once we obtain these data through an HTTP request, the subsequent processing is relatively simple. Whether it is to render data to an HTML template using backend languages (such as PHP, Python), or to parse JSON responses in front-end frameworks (such as Vue, React), it can be easily traverseddataArray, extract the content of each article'stitleanddescriptionfield and display it on the page.

Advanced application scenarios and practical suggestions

In practice, you may encounter some more complex requirements or need to consider performance optimization.

  1. Obtaining a specific article abstractIf your scenario is to know the ID or alias of an article alreadyurl_token),and only need to get the detailed information of this article (including the introduction), thenarchive/detailThe interface will be more direct. Just pass the article'sidorfilename(i.e.),url_token),can obtain all the data of the article, includingdescriptionfield. But if your purpose is to get a list,archive/listit is still a more efficient choice.

  2. front-end display optimizationWhen rendering the article list on the front-end page, you can use this obtained summary data to present it elegantly on the article list page, search results page, or related article recommendation module.For example, limiting the introduction to a certain number of characters, or adding a "Read More" link at the end of the introduction, can maintain the page's cleanliness and user experience.

  3. Performance optimizationWhen the number of articles on the website is large, how should it be used rationallylimitandpageIt is crucial to paginate parameters. Avoid fetching all article data at once, as this can significantly reduce server pressure and data transfer time, improving website loading speed.At the same time, caching the data obtained on the client side can also reduce duplicate requests and further optimize the user experience.

By flexibly using the AnQiCMS providedarchive/listInterface, we can easily achieve efficient extraction and display of article summaries, greatly enhancing the flexibility of website content management and user experience.This not only makes your website content more attractive, but also provides users with better navigation and information preview.


Frequently Asked Questions (FAQ)

1. If thedescriptionfield is empty or the content is too short, how should I handle it?

WhendescriptionWhen a field is missing or insufficient in content, in order to ensure the display effect, you can set a backup logic on the front-end or back-end. A common practice is to take an example from the article'scontentField extracts the first few words as a substitute for the introduction. AnQiCMS'sarchive/listThe interface does not automatically截取 for you, therefore this needs to be judged and processed at the code level after you receive the data.If the article content is not suitable for direct extraction, you can display a general prompt, such as 'No introduction available'.

2. How to avoid performance issues when getting a large list of articles?

It is most critical to make reasonable use to avoid performance issuesarchive/listinterface'slimitandpageParameter.

  • limitCan limit the number of articles returned in a single request, it is recommended to set a reasonable value according to the page layout and user experience (for example, 10-20 articles per page).
  • pagecooperatetype=pageThe parameter is used to enable pagination loading, only the data required for the current page is requested.In addition, you can also consider implementing lazy loading (Infinite Scroll) or infinite scrolling functionality on the front end, which loads the next page of content when the user scrolls to the bottom of the page, thus improving the user experience.

3.archive/listDoes the interface support retrieving the introduction of other content types (such as products, downloads)?

Yes,archive/listThe interface is generic. As long as you specify `

Related articles

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

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

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

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

What is the role of `url_token` in the AnQiCMS document list results, and how is it used to generate friendly URLs?

In AnQiCMS, `url_token` is a crucial concept, it is not only a field in the document list, but also the core element for building friendly URLs (Friendly URL) of the website.Understanding its role and usage can help us better optimize the website structure, improve user experience, and search engine rankings.

2025-11-09

How to ensure that only documents under the parent category are returned when retrieving the AnQiCMS document list, without including subcategories?

When using AnQi CMS to manage website content, we often encounter situations where we need to precisely control the display range of documents.For example, when you want to display only the documents directly published under a certain parent category page, without involving the content of its subordinate subcategories, you need to adjust the way the document list is retrieved.AnQi CMS provides a very flexible API interface, allowing you to easily meet this requirement.

2025-11-09

I want to display the number of comments for each article on the AnQiCMS document list page, which field should I check?

In the daily use of AnQiCMS, many operators hope to be able to directly display the number of comments for each article on the article list page.This not only effectively enhances the activity of the content, but also helps users quickly understand which articles are more popular and have more discussion value.Then, among all the data fields, which one should we focus on in order to meet this requirement?

2025-11-09

What is the significance of the `price` and `stock` fields returned by the `archive/list` interface for e-commerce document models?

In AnQi CMS, when you retrieve the document list through the `archive/list` interface, the returned data includes the `price` and `stock` fields, which are of vital importance for constructing an e-commerce website model.They are not just simple numbers, but are the core elements supporting product display, transaction process, and inventory management.

2025-11-09