How to accurately retrieve and display the content of a specified ID or URL alias on the document detail page?

Calendar 👁️ 56

AnQiCMS (AnQiCMS) is an efficient and flexible content management system that provides users with a rich set of tools to build and manage websites.During website operation, we often need to accurately display the detailed content of a document on a specific page, whether the document is the one being viewed on the current page or specified by a specific identifier (such as ID or URL alias).The AnQi CMS template tag system, especiallyarchiveDetailTags are the key to solving this demand.

Understand the core content display of AnQi CMS

One of AnQiCMS' core strengths lies in its powerful content model and highly customizable template system.The content model allows us to define different types of content structures based on business needs, while the template determines how these contents are presented on the front end.How to flexibly and accurately retrieve and display content on the document detail page is an indispensable part of template design and content operation.This is where the template tag plays a crucial role, seamlessly connecting background data with the front-end display.

archiveDetailTags: The core tool for precisely retrieving the content of specified documents

When we need to retrieve and display the details of a specific document on the document detail page,archiveDetailThe tag is our preferred tool. This tag allows us to accurately retrieve the corresponding document data based on the document's unique identifier (ID) or its friendly URL alias (token).

archiveDetailThe role of the tagLies in the fact that it can extract all available field information from the specified document, including title, content, images, categories, etc., and provide it for us to call in the template.

Key parameter analysis:

  • idParameterThis is the most direct way. Each document in AnQiCMS has a unique numeric ID. If we know the ID of the document to be displayed, we can directly pass throughid="[文档ID]"Specify precisely. For example, to get the title of the document with ID 5, you can use it like this:

    {% archiveDetail articleTitle with name="Title" id="5" %}{{articleTitle}}
    

    Here, we will assign the title obtained to a variablearticleTitleThen proceed{{articleTitle}}Display it.

  • tokenParameter:AnQiCMS supports setting URL aliases for documents, which is a more semantically meaningful and SEO-friendly identifier. If we want to access the document through this alias, we can usetoken="[URL别名]"This method is very convenient when it is necessary to display documents with specific "topic" or "fixed page" nature. For example, if there is a document about "company profile" with an alias asabout-usWe can call its content like this:

    {% archiveDetail aboutContent with name="Content" token="about-us" %}{{aboutContent|safe}}
    

    Please note,ContentFields usually contain HTML content, in order to ensure that it is rendered correctly rather than being escaped as plain text, it needs to be paired with|safefilter usage.

  • siteIdParameterFor users who have used the AnQiCMS multi-site management function, if they need to call data from other sites in the document detail page of the current site,siteId="[站点ID]"Parameters are particularly important. They ensure the cross-site accuracy of data calls. However, in most single-site scenarios, this parameter usually does not need to be manually set.

Common field calls: archiveDetailLabels can obtain various fields of the document, such as:

  • Id:Document ID
  • Title:Document title
  • Link:Document link
  • Description: Document introduction
  • Content: Main content of the document
  • Logo/Thumb: Cover image or thumbnail of the document
  • CreatedTime: Publication time of the document (can be配合stampToDateformatted)
  • and other fields defined in the custom content model.

Generally, if we are on the document detail page and we need to get the information of the current page's document, we can directly use a concise one.{{archive.Title}}/{{archive.Content}}As such, no additional specification is requiredidortokenBecause the system will automatically assign the current document object toarchiveVariable.

Custom document detail template: another option for deep customization

In addition to retrieving data flexibly through label parameters, AnQiCMS also provides another way for users who pursue ultimate customization to precisely control the display of specific documents -Custom document detail template.

According to the template conventions of AnQiCMS, we can create dedicated template files for specific documents or categories. For example, for a document with ID 10, we can create a file named{模型table}/detail-10.htmltemplate file (for example:)article/detail-10.html). When the user accesses this document, the system will automatically load this customized template instead of the general{模型table}/detail.htmlTemplate.

Moreover, in the background interface for 'publishing documents' or 'editing documents', there is a 'document template' field, where we can directly enter a custom template filename (for exampledownload.htmlThis means that you can design a special layout or functionality for a document (such as a software download page)download.htmlTemplate, and specify it in the background to achieve a completely independent display effect.This method has the advantage of allowing us to provide unique visual and interactive experiences for content with special operational purposes without modifying the general template.

URL alias and pseudo-static: SEO-friendly content identification

In AnQiCMS, URL alias is not justtokenThe foundation of parameter calling, it is also an important part of website SEO optimization.By setting a meaningful URL alias for the document, we can generate more readable and search engine friendly static URLs.

In the background "Function Management" menu, go to the "SEO Rules" settings, you can configure the URL generation mode. For example, if your SEO rules include {filename}The field, then the alias of the document's URL will be directly reflected in the final URL path.Maintaining the uniqueness of URL aliases is crucial to avoid content duplication and enhance user experience.AnQiCMS when creating or editing documents in the background, will automatically generate aliases based on the title and perform uniqueness checks. If there are duplicates, it will automatically append numbers to ensure uniqueness.

Practical suggestions and precautions

  1. Take advantage of the current contextIn the document detail page, if the target document is the same as the document being displayed on the current page, use it directly{{archive.Title}}/{{archive.Content}}Variables are the simplest and most efficient way, there is no need to go throughidortokenParameter is duplicated.
  2. Choose the ID and URL alias explicitly.:
    • ID: Suitable for internal references, background management, or other scenarios not directly exposed to users, as it is stable and unique.
    • URL alias (token): Suitable for scenarios where it is necessary to display a friendly URL, perform SEO optimization, or content has clear semantic identification. When called in the template, the alias is more readable.
  3. Ensure uniqueness: Whether it is a document ID or a URL alias, it should be a unique identifier.AnQiCMS will automatically handle the uniqueness issue of URL aliases, but as a content operator, we should still strive to ensure its clarity and uniqueness in the planning phase.
  4. Performance consideration: AlthoughsiteIdParameters allow cross-site data calls, but frequent or unnecessary cross-site data requests may increase system load. It is recommended to use it only when it is necessary to share or integrate content across multiple sites.
  5. Handling when content does not exist: If the document corresponding to the specified ID or URL alias cannot be found,archiveDetailTags usually return empty values. To avoid the page displaying blank or error messages, it is recommended to add conditional judgments (such as{% if article %}) to display friendly prompt messages when content does not exist.

By flexible applicationarchiveDetailTags, custom templates, and understanding URL alias and pseudo-static mechanisms allow us to achieve highly precise and efficient control over the content of document detail pages in AnQiCMS, thereby better serving the operational goals of the website.


Frequently Asked Questions (FAQ)

  1. How to display a specified ID's featured article in a specific area of the website homepage?You can directly use the tag in the homepage template file.archiveDetailto

Related articles

How to display thumbnails, descriptions, and custom fields on the document list page?

In website operation, the content list page is a key link for users to obtain information and decide whether to delve deeper into browsing.A richly informative, well-structured list page that can greatly enhance user experience and content appeal.It is particularly important to display thumbnails, descriptions, and custom fields reasonably in the document list page of Anqi CMS to achieve this goal.Through the powerful and flexible template tag system provided by Anqi CMS, you can easily meet this requirement without complex programming knowledge, just need to make simple modifications and configurations to the template file.

2025-11-07

How to manage and display all documents in AnqiCMS and support filtering by title, model, and category?

In the era of explosive digital content, efficiently managing and displaying website documents is a core challenge for every operator.When you have a vast amount of articles, product descriptions, service instructions, or any form of site content, how to ensure that these contents are organized, easy to find, and can be filtered according to different needs, is directly related to user experience and operational efficiency.AnqiCMS, as a system specially designed for enterprise content management, provides a powerful and flexible solution in this aspect.

2025-11-07

How to dynamically display the list of articles or products under a category in the navigation dropdown menu?

AnQi CMS: Build dynamic dropdown navigation menus to make content easily accessible In website operation, the navigation menu is the starting point for users to explore website content, and it is also an important clue for search engines to understand the website structure.The traditional navigation menu is often fixed links, when the website content becomes increasingly rich, especially when there are many articles and product types, manually maintaining the content list in the dropdown menu becomes particularly繁琐 and prone to errors.The AnQi CMS provides us with an elegant and efficient solution with its powerful content management capabilities

2025-11-07

How to judge the current link status in the navigation list tags and add a highlight style?

In website operation, clear navigation is a key factor in improving user experience.When users can intuitively see their location on the current page, it not only reduces the sense of being lost but also improves the professionalism and usability of the website.Adding a highlight style to the current link in the navigation bar is a very effective way to achieve this goal.In Anqi CMS, highlighting the current link of the navigation item is actually simpler and more direct than you imagine.

2025-11-07

How to use the `archiveDetail` tag to display images, view counts, and publishing time on the document detail page?

In website operation, the document detail page is the core area that attracts users and conveys information.A rich content, intuitive detail page, which can not only significantly improve user experience, but also has a positive push on search engine optimization (SEO).AnQiCMS provides a powerful `archiveDetail` tag that allows us to easily obtain and display various document information, such as images, view counts, and publication time.Next, we will explore how to skillfully use the `archiveDetail` tag in the document detail page

2025-11-07

How to correctly render Markdown content as HTML and display mathematical formulas and flowcharts in the Anqi CMS template?

The content is the soul of the website, and how to present these contents efficiently and beautifully is a topic of concern for every operator.In AnQi CMS, using Markdown to write content not only greatly improves writing efficiency, but also easily achieves complex layout requirements, such as inserting mathematical formulas and drawing flowcharts. This is undoubtedly a powerful feature for technical blogs, educational websites, or corporate websites that need to display complex business processes.Next, we will explore how to correctly render Markdown content as HTML in the Anqi CMS template

2025-11-07

How to use the `archiveList` tag to display a document list according to specified conditions (such as latest, most popular, recommended attributes)?

AnQiCMS is an efficient and flexible content management system that provides a variety of content display methods, among which the presentation of the document list is a very core part of website operation.We hope to dynamically display the latest articles, the most popular content, or carefully recommended high-quality documents on the homepage, category pages, or thematic aggregation pages according to different operational objectives.All of this can be easily achieved through the powerful `archiveList` tag of AnQiCMS

2025-11-07

How to implement a paginated document list display in `archiveList`?

When managing website content, we often encounter such situations: there are many articles, products, or news under a certain category. If all the content is piled on a single page, it not only causes the page to load slowly and affects user experience, but also makes it difficult for visitors to find what they need in a sea of information.At this point, introducing pagination becomes particularly important. Pagination can break a large amount of content into several small pages, allowing users to browse page by page, greatly enhancing the usability and access efficiency of the website.In AnQiCMS, implementing a document list display with pagination is very intuitive and flexible

2025-11-07