How to get the list of all tags (Tags) associated with the current document details?

Calendar 👁️ 70

In Anqi CMS, tags are an important tool for organizing content, enhancing user experience, and optimizing search engine rankings.They can help visitors quickly find relevant content, and also allow website administrators to better manage information.When we browse a document detail page, we often hope to see a list of all tags associated with the document, which can not only guide users to discover more related content but also enrich the semantic structure of the page.

To obtain the tag list associated with a specific document, we usually need to perform two steps: first, determine the unique identifier of the target document, and then use this identifier to request the associated tag data.

Step 1: Obtain the unique identifier (ID) of the document

In Anqi CMS, each document has a unique ID. This is the key for obtaining tags later. You can access it byarchive/detailAn interface to retrieve detailed information about a single document, which includes this ID.

The calling method of this interface isGET. You can specify the document to query in two ways:

  1. Using the document ID:If you already know the document's numeric ID, you can pass it directly asida parameter.
  2. Use the document URL alias:If you know the document's URL alias (filename),can also be used to query.

For example, if you know the ID of a document is 1, you can send a GET request to{域名地址}/api/archive/detail?id=1send a GET request.

After the interface successfully returns, you will see the data returned in thedataFind a field namedidinteger value, this is the unique ID of the document. You will also see the document'skeywordsThe field, which is usually a collection of keywords in the document, but it is not the structured tag list we are looking for.

Step two: Use the document ID to obtain the associated tag list.

With the unique ID of the document, it becomes very direct to obtain the associated tags. Anqi CMS provides a specialtag/listAn interface that can list all related tags based on the document ID.

You also need to useGETa method to call this interface. The most critical parameter isitemIdYou need to assign the document ID obtained in the first step to this parameter.

For example, if the document ID obtained in the first step is 1, then you can send to{域名地址}/api/tag/list?itemId=1send a GET request.

The interface returns an array containing tag objectsdataEach object in the array represents a tag, which usually includes the following important information:

  • id: The unique ID of the tag.
  • title: The name of the tag, which is the text we usually see.
  • url_token: The URL alias of the tag, which can be used to build the exclusive link of the tag.
  • link: The detail page link of the tag, click to view all documents containing the tag.

By traversing thisdataAn array, you can get all the tags associated with the current document, and you can display them in any position on the page as needed, such as below the article content, or in the sidebar.

Summarize the workflow

The entire process of obtaining document-related tags can be summarized as:

  1. ByGET {域名地址}/api/archive/detail?id={文档ID}(or use)filename)Get the detailed information of the current document, and extract the document'sid.
  2. Then, use thisidasitemIdThe parameter, callGET {域名地址}/api/tag/list?itemId={文档ID}To get the detailed list of all tags associated with the document.

This two-step operation not only clearly separates document information and tag information, but also provides developers with flexible data acquisition methods. When displayed on the front end, you can utilizetitleAs label text,linkAs a hyperlink for the label, thus constructing an interactive label cloud or a related content navigation area, greatly enhancing the user's browsing experience.


Frequently Asked Questions (FAQ)

Q1: If the document has not set any tags,tag/listWhat will the interface return?

A: If the document is not associated with any tags,tag/listinterface'sdataThe field will return an empty array. This means that when you are handling the API response, you need to checkdataWhether the array is empty, if it is empty, you can choose not to display the label area, or display prompts such as 'No labels available'.

Q2:archive/detailThe interface returnskeywordsandtag/listThe data obtained from the interfacetagsWhat is the difference?

A:archive/detailthe interface inkeywordsFields are typically keywords in a document, they are plain text, such as 'AnQi CMS, CMS system, website tutorial', mainly used for SEO purposes, to inform search engines of the document's topic. And throughtag/listThe data obtained from the interfacetagsis a structured array of tag objects, each tag has its own ID, title, and independent link.In AnQi CMS, these tags are considered independent content entities, more suitable for building clickable tag clouds or related content navigation, with stronger interactivity and content aggregation capabilities.

Q3: Can you directly get the label of a document without first obtaining its details?

A: You cannot directly retrieve the tag list of a specific document without knowing the document ID.tag/listinterface'sitemIdThe parameter is required, it explicitly indicates which document's label to query.Therefore, obtaining the document ID is a prerequisite step for obtaining its associated tags.Of course, you can use other methods (such as througharchive/listSearch for the interface document, then extract the ID from the search results to obtain the document ID, but in the end, we all need the document ID to calltag/listinterface.

Related articles

Is there a recommended word limit or **practice** for the `description` field in the document details?

In the daily use of AnQi CMS, the `description` field is a seemingly insignificant but extremely important part.It is not just a brief summary of the content, but also a bridge of communication between the website content, search engines, and users.A well-written description that can effectively improve the click-through rate of articles in search results and help search engines better understand the content theme.According to the AnQi CMS documentation, when publishing or importing a document (archive), the `description` field has a clear recommendation

2025-11-09

In addition to retrieving the details of a single document, does Anqi CMS provide an interface to obtain the list of documents under a specific category or model?

When building a website with AnQiCMS, we often have such doubts: In addition to being able to accurately obtain the detailed information of a specific document, does the system also provide a function to obtain a list of all documents under a certain category or model at one time?The answer is affirmative. Anqi CMS fully considers the flexibility of content management and display, providing powerful interfaces to meet such needs.To retrieve the document list under a specific category or model, it mainly relies on the `/api/archive/list` interface provided by AnQi CMS

2025-11-09

What are the considerations for replacing `{domain address}` during deployment?

When using AnQiCMS for secondary development or integrating with external systems, you will often encounter placeholders like `{domain address}` in the API interface documentation.This represents the actual URL where your Aiqi CMS is deployed.Correctly replace this placeholder is the basis to ensure API call success and system stable operation.Understand the meaning behind it and master the precautions when replacing, which can help you interact with AnQiCMS more efficiently.Firstly, `{domain address}` is essentially a variable

2025-11-09

If the `images` field is `null`, does it mean that the document is not associated with any images?

When using AnQi CMS to manage website content, we often deal with API interfaces to retrieve or submit various data.Among them, image data is an indispensable part of the website content, and regarding the return form of the `images` field in the document, it sometimes causes some confusion: Does it really mean that the document has no pictures associated with it when the `images` field returns `null`?### Learn the concept of "Gallery" in Anqi CMS In the document structure of Anqi CMS, images are usually divided into several types: *

2025-11-09

The `data.category` field (such as 1 or 3) represents what type of attribute the classification has?

When using Anq CMS for website content management or secondary development, you may notice that in the data returned by the classification or document detail interface, there is a `type` field under `data.category`. This field's value is usually `1` or `3`, what does it represent in terms of classification, and what practical significance does it have for our content organization and website presentation?Understanding this is very critical for more efficient use of Anqi CMS for website content planning and maintenance.In short

2025-11-09

How to implement the increase of document views (`views`) or update of other fields through API?

When you are running a website, you often need to manage content data in a fine-grained manner, such as tracking the number of views of articles, or modifying other properties of documents in specific scenarios.AnQiCMS provides a powerful API interface, making these operations possible.This article will introduce you in detail on how to use these interfaces to increase the document page views or update other fields. ## Learn about the API interaction mode of Anqi CMS In Anqi CMS, operations on document data are mainly divided into retrieval (read) and writing (creation/modify).for reading data

2025-11-09

How to optimize API requests to improve user experience when loading document details on the front-end page?

In website operation, user experience is always a core consideration. When visitors click into a document detail page, they expect a smooth, fast and secure content loading experience.AnQiCMS (AnQiCMS) provides a powerful and flexible API interface, allowing us to carefully design the document loading mechanism of the front-end page, thereby significantly improving user satisfaction.**Understanding the Core: The Power and Details of the `archiveDetail` Interface** When we talk about loading document details, the focus is initially on the `archiveDetail` interface

2025-11-09

If multiple recommended properties exist in the `flag` field (such as 'hc'), what characteristics does the document have simultaneously?

How to make important information stand out in the vast sea of content on a website and be discovered by users first is the focus of every operator.AnQiCMS (AnQiCMS) provides us with a very flexible and powerful tool for managing the display priority and characteristics of content - that is the `flag` field.This little field, yet contains huge potential for content operation.The mystery of the `flag` field: the叠加effect of multiple attributes In Anqi CMS, the `flag` field plays the role of document "recommended attribute" or "characteristic mark".

2025-11-09