How to get the document list with 'Headline' or 'Slide' recommended attributes (`flag`) in AnQiCMS?

Calendar 👁️ 74

In AnQiCMS (AnQiCMS), content operators often need to flexibly display important content on the website, such as setting specific articles as 'headline' or 'slideshow' to attract users' attention. AnQiCMS provides a very practical feature for this, which is to use 'recommended attributes' (flag) to mark the document. If you want to get the list of documents marked specially, you can easily achieve this with the AnQiCMS API interface.

Understanding the "recommended attributes" of the document (flag)

In Anqi CMS, each document may have one or more recommended attributes, which are marked with single letters for easy classification and display on the website. For example:

  • HeadlineUsehA tag, usually used in the most prominent position on the homepage to display the most important content.
  • SlideUsefLabel, commonly used in carousel or slide show area, attracting users with images and titles.
  • Other common properties include: recommendedc, special recommendationa, scrolls, boldh(Note, herehIt can represent both headline and bold, but it is usually agreed upon in content management), imagep, jumpjetc.

A document can have multiple properties, such as both 'headline' and 'slide', so itsflagvalue may behf. Understanding these tags is the basis for obtaining a specific list of documents.

Usearchive/listRetrieve document list from the interface

To retrieve a document list with specific recommendation attributes, we need to utilize the Anqi CMS providedarchive/listInterface. This is a very powerful interface that allows you to filter documents based on multiple conditions.

Basic interface information

  • API call address:{域名地址}/api/archive/list
  • Call method:GET

Core parameters:flag

Inarchive/listAmong the many request parameters of the interface,flagthe parameters are the key to achieving our goal. It allows you to specify the recommended attributes to match.

How to useflagparameters:

  1. Retrieve documents with a single recommendation attributeTo retrieve all documents marked as 'Headline', justflagthe parameter toh, that isflag="h". Similarly, to retrieve 'Slide' documents isflag="f".
  2. Retrieve a document with one of multiple recommended attributesIf you want to retrieve thoseeither "Headline" or "Slideshow"documents, you can use multipleflagvalues separated by commas,Separate. For example, to get documents such as 'Headline' or 'Slide', the parameter is set toflag="h,f". At this point, as long as theflagattribute containshorfany one of them, it will be retrieved.

Combine other practical parameters

exceptflagIn addition, you usually need to work with other parameters to accurately control the returned results:

  • moduleId: It is strongly recommended to specify the model ID of the document you belong to, for example, the article model ID is usually1This can prevent the retrieval of documents from other models (such as product models), ensuring data consistency. For example,moduleId=1.
  • limit: Controls the number of returned documents. If you only need to display a few, you can setlimit=5. If you need pagination, you can also uselimit="2,10"to specify starting from the 2nd item and getting 10 items.
  • typeWhen you need to get the total count and display it with pagination, you can settype="page". If you just need to get a list, the defaultlisttype is enough.
  • order: You can set the sorting method as needed, for exampleorder="created_time desc"This means sorting in reverse order by publication timeorder="views desc"This means sorting in reverse order by views

Actual operation example

To better understand, let's look at some specific API request examples. Assuming your website domain iswww.yourdomain.com, the article model ID is1.

1. Get all the latest articles marked as 'Headline', up to 5 articles:

{域名地址}/api/archive/list?moduleId=1&flag=h&limit=5&order=created_time desc

Replace{域名地址}Withhttps://www.yourdomain.com, the complete request would look like:https://www.yourdomain.com/api/archive/list?moduleId=1&flag=h&limit=5&order=created_time desc

2. Get all popular articles marked as 'Slide', without limiting the number and supporting pagination:

{域名地址}/api/archive/list?moduleId=1&flag=f&type=page&order=views desc&page=1&limit=10

This will get all articles under the article model,flagincludingfThe document properties, sorted by view count in descending order, 10 items per page, get the first page.

3. Get all documents marked as "Headline" or "Slideshow" and display 3 randomly.

{域名地址}/api/archive/list?moduleId=1&flag=h,f&limit=3&order=rand()

(Please note,rand()Not all databases or APIs support it, this is for demonstration purposes, and in practice, it may require backend support or random selection on the frontend)

Interpret the returned data

After you make a request, the interface will return a JSON-formatted data. A successful response will includecode: 0and adataAn array where each element is a document object. You can findtitle/description/thumb(thumbnail),link(document link) and the ones we are interested inflagField information. Through this data, you can display selected document content on your website.

By following these steps, you can accurately obtain a list of documents with specific recommendation properties in AnQiCMS, providing strong support for your website content operation.


Frequently Asked Questions (FAQ)

Q1: How should I set the API request to retrieve documents that have both the 'Headline' and 'Slide' properties?A1: Anqi CMS'flagThe parameter is designed to match the "or" relationship by separating with commas (i.e., including any specified attribute). If a document has bothhandfproperties (such as itsflagfield value ishf), then you pass throughflag="h"orflag="f"evenflag="h,f"Can get it. There is no direct "AND" logical filtering method at the API level, but usually a document marked as "headline" and "slide", itsflagThe field will include itselfhandf,flag="h,f"It can meet most 'or' relationship needs.

Q2:moduleIdWhy is the parameter so important, what if I don't specify?A2:moduleIdUsed to specify the model to which the document belongs, such as articles, products, images, etc. The structure of documents under each model may vary, and the content may be very different. If not specifiedmoduleIdAn interface may search all models, leading to the return of irrelevant data or a data structure that does not meet your expectations, which may affect the accuracy of front-end display. Specify explicitly.moduleIdEnsure that you obtain the content under the target model, improving data accuracy and interface efficiency.

Q3: How to display the content of the document list on my website after obtaining it?A3: After obtaining the JSON data of the document list, you need to parse these data according to your front-end technology stack (such as HTML, CSS, JavaScript, or Vue/React frameworks), and you will usually iterate over them.dataAn array, dynamically generates HTML elements for each document, displaying its title, thumbnail, introduction, and links to the document detail page. You can use the returned data intitle/thumb/descriptionandlinkThe field is formatted and rendered to form a beautiful 'headline' or 'slideshow' area on the website.

Related articles

Does the AnQiCMS document list interface support excluding multiple categories of documents at the same time (`excludeCategoryId` usage)?

In website operation, we often need to flexibly display content, such as displaying the latest articles on a page, but not including content under certain specific categories, such as announcements or internal news.AnQiCMS as a powerful content management system, provides a rich set of API interfaces to meet these complex display requirements.Today, let's delve into a very practical parameter of the `archive/list` interface: `excludeCategoryId`, especially how it supports excluding multiple categories of documents.###

2025-11-09

How to filter the AnQiCMS document list to display articles under a specific category (`categoryId`)?

How to accurately filter out articles under specific categories when managing and displaying a large amount of content in Anqi CMS is a key link to improve the organization of website content and user experience.Strong and flexible interfaces are provided by AnQi CMS, allowing us to easily achieve this goal.This article will provide a detailed introduction on how to use the document list interface of Anqi CMS to only display specific categorized articles that you hope to see.### Master the document list interface: the core of content filtering To filter articles under specific categories, we need to use the `/api/archive/list` interface provided by AnQi CMS

2025-11-09

How to implement descending order by publish time, view count, or update time in the AnQiCMS document list?

In website operation, how to efficiently present content lists so that users can quickly find the information they are most interested in or most valuable is an important issue.AnQiCMS provides a flexible document list feature, allowing us to easily implement content list sorting in descending order based on multiple conditions, such as publication time, page views, or update time.This not only optimizes the user experience, but also helps to improve the visibility and interaction of the content.

2025-11-09

How to precisely control the number of documents returned and the starting offset of AnQiCMS document list (advanced usage of `limit` parameter)?

When building and managing website content, AnQiCMS provides a series of flexible API interfaces to help us accurately obtain and display data.Among them, the `archive/list` interface is the core for obtaining the document list, and its `limit` parameter demonstrates its powerful fine-grained control capabilities in terms of controlling the number of returned items and the starting offset.Understand and master the advanced usage of the `limit` parameter, which can make our website content display more flexible and efficient.### `limit` parameter basic usage

2025-11-09

How does the `child=false` parameter affect the display of categories and their subcategories when retrieving the document list?

In Anqi CMS, the `archive/list` interface is the core tool for obtaining the list of website documents, which provides a variety of parameters to help us accurately filter and display content.Among them, the `child` parameter, although simple in appearance, plays a vital role in the display of categories and their subcategories in documents, directly affecting the granularity of content presentation.Understand and make good use of this parameter, it can make the content organization of your website clearer and improve the user experience.By default, when you access `archive/list`

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

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

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