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