How to get the details of a document through the document URL alias (`filename`)?

Calendar 👁️ 73

In Anqi CMS, the document URL alias (filenameIt is a very practical feature, which not only makes your website URL more friendly and improves SEO, but also provides great convenience in content acquisition.When you need to obtain detailed information about a specific document through programming, AnQiCMS provides a simple and intuitive API interface.

Core feature revelation: Use document URL alias to get details

To get all the details of the document's URL alias, you will mainly use Anqi CMS'sarchive/detailInterface. This interface is designed to be very flexible, allowing you to accurately retrieve content through the unique ID of the document or its set URL alias.

Imagine that your website has an article about 'AnQi CMS Beginner's Guide', and its URL alias may be set toanqi-cms-guide. When you want to display the full content of this article in a custom page template, mini-program, or any other application, you can directly use this alias for the request without knowing its internal database ID.

How to build a request to get document details

The API address for requesting document details is usually like this:{域名地址}/api/archive/detail. Among them,{域名地址}Replace it with the domain name of your actual website.

The calling method of this interface isGETThis means you can pass request information through URL parameters. There are two core parameters:idandfilenameThey are mutually exclusive, which means you only need to choose one to identify the document you want to retrieve.

You will use for the topic we are discussing today.filenameParameters. For example, if you want to get the URL alias namedanqi-cms-guidedocument, the request URL will be similar to:

https://www.yourdomain.com/api/archive/detail?filename=anqi-cms-guide

After sending such a GET request, AnQi CMS will return all detailed information corresponding to the alias.

Understand the returned data structure deeply

After successfully retrieving the document details, the API will return a JSON-formatted data. This package contains everything you need. Typically, you will see the following key components:

  • codeandmsgThese two fields are the basis of each API response.code0 indicates that the request was successful,msgThe operation result will be provided in text. If there is an error, it will also give the corresponding error code and reason.

  • dataobject: This is the carrier of all document details. It includes basic properties of the document, such as:

    • id: The unique ID of the document.
    • title: The title of the document.
    • seo_title,keywords,description: This is used for search engine optimization metadata.
    • url_token: This is what we input.filenamethat is the document's URL alias.
    • views,comment_count: Document views and comments.
    • created_time,updated_time: Document's publish and update timestamp.

    It is worth mentioning that the actual content and classification information of the document will be indata.dataanddata.categorythese nested objects.

    • data.data.content: The rich text content of the document, which is usually in HTML format and can be rendered directly on the front-end.
    • data.category: Contains detailed information about the document's category, such as category ID, category name (title), category URL alias (url_token) and so on.
    • data.extra: If your document model has set custom fields, the content of these fields will be presented in thisextraobject in the form of key-value pairs, for example{"author": {"name": "作者", "value": "AnqiCMS"}}This allows your content to have very rich custom attributes.

By parsing these returned data, you can flexibly display document titles, summaries, main content, publication time, and even author information, etc., on the front-end page.

Actual application scenarios and advantages

UsefilenameTo get document details, especially suitable for the following cases:

  1. Build a front-end page: When you are developing a custom frontend interface, if your routing design is based on URL aliases, then you can directly go throughfilenamequeries can simplify the logic of data acquisition.
  2. SEO-friendlyIn front-end frameworks like Vue, React, or mini-programs, when generating SEO-friendly URLs, filenameCan better correspond to these URLs, maintain consistency of front-end and back-end data requests.
  3. Content migration or synchronization: When importing content or integrating with third-party systems, if the alias is used as a unique identifier, then usefilenameIt can conveniently locate and retrieve specific content.

The advantage of this method lies in the fact that it provides a human-readable, easy-to-manage, and search engine-friendly way to reference and access content on a website, which is more semantically meaningful than simply using a numeric ID.

Summary

Anqi CMS passedarchive/detailthe API and combine withfilenameParameter, it provides you with an efficient, flexible, and easy-to-understand way to obtain document details.In order to optimize SEO, custom development, or content management, mastering this feature will greatly enhance your work efficiency and website user experience.


Frequently Asked Questions (FAQ)

  1. Q: If I have not set a URL alias for the document, can I still usefilenameparameters to get document details?A: No.filenameThe parameter must be passed in the URL alias set in the AnQi CMS background.If the document has not set an alias or you have entered an incorrect alias, the API will not be able to find the corresponding document and will return an error message.In this case, you should use the unique ID of the document (idto get the details.

  2. Q:filenameandidWhich one will be used first when both parameters are passed in?A: Based on the provided document description,idandfilenameIt is an either/or parameter. This means you only need to pass one of them.In most cases, APIs have an internal priority judgment logic, but to ensure the clarity and efficiency of the request, it is recommended that you only pass a valid identifier parameter each time.If you know the document ID clearly, using the ID might be a bit more direct;If you prefer semantically meaningful URLs, then usefilename.

  3. Q: Return data in theextrafield can be used specifically for what?A:extraThe field is a very flexible feature of AnQi CMS, used to store additional field data that you customize for the document model in the background. For example, if you add custom fields such as "author", "source", or "reading time" to the "article" model, the values of these fields will be displayed inextraIt returns. By parsingextraYou can display these rich custom information on the front end, thereby better meeting the diverse content display needs.

Related articles

How can you get the document details of Anqi CMS by document ID?

When using AnQi CMS to manage website content, we often need to retrieve detailed information about specific documents from the backend, whether it is to display content on custom pages or integrate data into other systems (such as mini-programs, mobile applications, etc.).AnQi CMS provides a powerful and flexible API interface, one of the core functions of which is to obtain specific document details through the document ID.Today, let's dive deep into how to use the document ID to easily obtain the details of Anqi CMS documents, making your content operations more efficient and automated.### Core Steps

2025-11-09

How to calculate the number of times a specific keyword appears in a string or array using the `count` filter in AnQiCMS templates?

During the template development process of AnQiCMS, we often need to perform dynamic data analysis or display of page content, such as counting the frequency of a keyword or checking the number of specific elements in a list.At this time, the `count` filter has become a very practical tool.It can help you quickly and efficiently calculate the number of times a specific keyword appears in a string or array, providing the possibility of flexible template presentation.--- ### `count` filter: Accurately count your content In short, `count`

2025-11-09

In AnQiCMS template, how to add a recommended icon to the article title based on the boolean state of the `item.Flag` attribute?

When managing website content in AnQiCMS, we often hope to highlight important articles through some intuitive visual elements, such as adding a prominent small icon to recommended content.This not only attracts the attention of visitors, but also helps them quickly find high-quality information on the website.It is fortunate that AnQiCMS has built-in `item.Flag` properties and a flexible template engine, making it very easy to implement this requirement.This article will discuss in detail how to use the `item.Flag` attribute status in the AnQiCMS template

2025-11-09

How to determine if the boolean value of a custom field in the AnQiCMS template is true and dynamically add a CSS class?

In AnQiCMS template development, we often need to adjust the display style of the page based on the specific attributes of the content.This includes dynamically adding CSS classes based on the boolean value of custom fields (i.e., true or false status), thus achieving a more flexible and expressive interface.AnQiCMS with its flexible content model design allows users to create various custom fields for different content types (such as articles, products).These custom fields greatly enrich the expression of content, enabling templates to be highly customized for different business needs.###

2025-11-09

If both `id` and `filename` parameters are provided, which one will the AnQi CMS document detail interface prioritize?

In AnQi CMS, getting document details is a very frequent operation in our daily operation.We usually request document data through the unique numeric identifier `id` or the user-friendly URL alias `filename`.

2025-11-09

What error message will the interface return if the document does not exist when getting the document details?

In the daily operation and development of Anqi CMS, we often need to retrieve website content through API interfaces, among which the 'Get Document Detail Interface' (`/api/archive/detail`) is undoubtedly one of the most frequently used ones.This interface allows us to retrieve the details of a specific article or product by document ID or URL alias (filename).However, during use, we are bound to encounter such situations: When the requested document does not exist in the system, what kind of error message will the interface return?This is for front-end page display

2025-11-09

What HTTP request methods does the AnQi CMS document detail interface support?

When building websites or developing various applications, we often need to obtain detailed information about articles or documents from a content management system (CMS).AnQiCMS (AnQiCMS) is a powerful content management platform and naturally provides such an interface, allowing developers to flexibly obtain various document content on the website.So, when we want to get the specific article through the document detail interface of Anqi CMS, which HTTP request method should we use?

2025-11-09

How to extract the complete content of the document from the returned data of the document detail interface?

In website operation, we often need to dynamically obtain and display the articles or product details of the site.AnQiCMS (AnQiCMS) provides a powerful and flexible API interface, making this process very convenient.Among them, the interface for obtaining document details is one of the core ones, which not only returns the basic information of the document but also allows you to easily obtain the complete content of the article.This article will guide you on how to accurately extract the complete content of the document from the document detail interface return data of Anqi CMS.

2025-11-09