In Anqi CMS, the document URL alias (filenameIt is a very practical feature, which not only makes your website URL more friendly and improves the search engine optimization (SEO) effect, but also provides great convenience in content acquisition.When you need to retrieve 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, you will mainly use the Anqi CMS.archive/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 "Enterprise CMS Getting Started Guide", and its URL alias may be set toanqi-cms-guide.When you want to display the full content of this article on a custom page template, miniprogram, or any other application, you can directly use this alias for the request without needing to know its internal database ID.

How to build requests to get document details

The API address for requesting document details is usually like this:{域名地址}/api/archive/detail.{域名地址}It needs to be replaced with the domain name of your actual website.

The calling method of this interface isGETThis means that 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 foranqi-cms-guidethe document, your request URL will be similar to:

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

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

Deep understanding of the returned data structure

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

  • codeandmsgThese two fields are the basis of each API response.code0 means the request was successful,msgThe operation result will be provided in text. If an error occurs, it will also provide 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: Meta information for search engine optimization.
    • url_token: That is what we input.filenameIt is also the URL alias of the document.
    • views,comment_count: Number of document views and comments.
    • created_time,updated_time: Timestamp of document publication and update.

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

    • data.data.content: The rich text content of the document, usually in HTML format, can be rendered and displayed directly on the front-end.
    • data.category: 包含文档所属分类的详细信息,如分类ID、分类名称(English)title)、分类URL别名(English)url_token)etc.
    • data.extra: If your document model has set custom fields, the content of these fields will be presented in the object in the form of key-value pairs, for exampleextra对象中以键值对的形式呈现,例如{"author": {"name": "作者", "value": "AnqiCMS"}}This makes your content have very rich custom attributes.

Through parsing these returned data, you can flexibly display document titles, summaries, body, publishing time, and even author information, etc. in the frontend page.

Application scenarios and advantages

UsefilenameGet document details, especially suitable for the following situations:

  1. Build front-end pages: When you are developing a custom frontend interface, if your routing design is based on URL aliases, then accessing it directly can simplify the data retrieval logic.filenameQuery can simplify the data retrieval logic.
  2. SEO-friendly: In front-end frameworks such as Vue, React, or小程序, generating SEO-friendly URLs,filenameIt can better correspond to these URLs, maintaining consistency between front-end and back-end data requests.
  3. Content migration or synchronizationIn the process of importing content or integrating with third-party systems, if the alias is used as a unique identifier, then usefilenameIt can be easily located and retrieved specific content.

The advantage of this method is that it provides a human-readable, easy-to-manage, and SEO-friendly way to reference and retrieve content on a website, which is more semantically meaningful than simply using a numeric ID.

Summary

Secure CMS througharchive/detailthe interface, and combinefilenameParameters, it provides you with an efficient, flexible, and easy-to-understand way to obtain document details.Whether it is for SEO optimization, custom development, or content management, mastering this feature will greatly enhance your work efficiency and the user experience of your website.


Common Questions (FAQ)

  1. Q: If I have not set a URL alias for the document, can I usefilenameparameters to get the document details?A: No.filenameThe parameter must be passed in the URL alias set in the AnQi CMS backend to take effect.If the document has not been set with an alias, or if you have entered an incorrect alias, the API will not be able to find the corresponding document and will return an error message.idparameters) to get the details.

  2. Q:filenameandidWhen both parameters are passed, which one will be used first?A: English according to the provided document description,idandfilenameIs a 'either/or' parameter.This means you only need to pass one of them.In most cases, an API will have an internal priority judgment logic, but to ensure the clarity and efficiency of the request, it is recommended that you pass only one valid identifier parameter each time.filename.

  3. Q: Return the data in the,extraspecific field can be used for what??A:extraThe field is a very flexible feature of AnQi CMS, used to store additional field data 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 appear inextraautoextraauto