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 display the detailed content of a specific document accurately on a particular page, regardless of whether this document is the one being viewed on the current page or specified by a specific identifier (such as ID or URL alias).archiveDetailTags are the key to solving this need.
Understanding the core content display of AnQin CMS
One of AnQiCMS's 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 requirements, while the template determines how these contents are presented on the frontend.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 template tags play a crucial role, seamlessly connecting backend data with frontend display.
archiveDetailTag: The core tool for accurately retrieving specified document content
When we need to retrieve and display the detailed information of a specific document on the document detail page,archiveDetailThe label is our preferred tool.This label allows us to accurately obtain the corresponding document data based on the unique identifier (ID) of the document or its friendly URL alias (token).
archiveDetailThe role of the labelIt lies in the fact that it can extract all available field information from the specified document, including title, content, images, categories, etc., and make it available for us to call in the template.
Key parameter parsing:
idParametersThis is the most direct way. Every document in AnQiCMS has a unique numeric ID. If we know the specific ID of the document we want to display, we can access it directly.id="[文档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 assign the obtained title to a variable
articleTitleand then through{{articleTitle}}and display it.tokenParameters:AnQiCMS supports setting URL aliases for documents, which is a more semantically meaningful and SEO-friendly identifier. If we want to retrieve the document using this alias,token="[URL别名]"This method is very convenient when it is necessary to display documents of specific 'topic' or 'fixed page' nature. For example, if there is a document about 'company profile' with an alias ofabout-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 instead of being escaped as plain text, it needs to be used in conjunction with|safefilters.siteIdParameters:For 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]"The parameter is particularly important. It ensures 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 call:
archiveDetailLabel can obtain many fields of the document, such as:
Id: Document IDTitle: Document TitleLink: Document LinkDescription:Document introductionContent: Main content of the documentLogo/Thumb: Cover image or thumbnail of the documentCreatedTime: Publication time of the document (can be used withstampToDateformat)- and other fields defined in the custom content model.
Generally, if we are on the document details page and we need to get the information of the current page's document, we can use a concise{{archive.Title}}/{{archive.Content}}等形式,而无需额外指定idortoken,因为系统会自动将当前文档对象赋给archivea variable.
自定义文档详情模板:深度定制的另一种选择
In addition to flexibly retrieving data through tag parameters, AnQiCMS also provides another precise way for users who pursue ultimate customization to control the display of specific documents.Custom document detail template.
According to AnQiCMS template conventions, 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.htmlThe template file (e.g.,article/detail-10.html). When the user accesses this document, the system will automatically load this customized template instead of the generic{模型table}/detail.htmltemplates.
In addition, in the interface for "Publish Document" or "Edit Documentdownload.htmlThis means that you can design a special layout or functionality for a document that requires it (such as a software download page)download.htmlTemplate, and specify it in the background to achieve a completely independent display effect.The advantages of this approach are that it allows 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 onlytokenThe foundation of parameter calls, and also an important part of website SEO optimization.By setting meaningful URL aliases for documents, we can generate pseudo-static URLs that are more readable and SEO-friendly.
In the "Feature Management{filename}The field, so the alias of the document's URL will directly appear in the final URL path.Maintaining the uniqueness of URL aliases is crucial for avoiding content repetition and enhancing user experience.AnQiCMS in the background creates or edits documents, it will automatically generate aliases based on the title, and perform uniqueness verification. If there are duplicates, it will automatically append numbers to ensure uniqueness.
Practical suggestions and precautions.
- Prioritize using the current contextIn the document detail page, if the target document is the document currently being displayed on the page, use it directly
{{archive.Title}}/{{archive.Content}}These variables are the simplest and most efficient way, no need to go throughidortokenParameter repetition detected. - Explicitly select ID and URL alias:
- ID: Suitable for internal references, background management, or other scenarios not directly exposed to users, as it is stable and unique.
- URL Alias (token):Applicable to scenarios where a friendly URL is needed for external display, SEO optimization, or content with clear semantic identification. When called in the template, the alias has better readability.
- Ensure uniquenessWhether it is a document ID or URL alias, it should be a unique identifier.AnQiCMS will automatically handle the uniqueness of URL aliases, but as content operators, we should still strive to ensure their clarity and uniqueness from the planning stage.
- Performance considerationsAlthough
siteIdThe parameter allows cross-site data calls, but frequent or unnecessary cross-site data requests may increase the system burden. It is recommended to use it only when there is a real need to share or integrate content across multiple sites. - The handling when content does not exist: If the document corresponding to the specified ID or URL alias cannot be found,
archiveDetailLabels often return empty values. To avoid displaying blank or erroneous information on the page, it is recommended to add conditional judgments (such as{% if article %}), so that friendly prompts are displayed when content does not exist.
By using flexibilityarchiveDetailTags, custom templates, and understanding URL aliases and pseudo-static mechanisms allow us to achieve highly precise control and efficient display of document detail page content in AnQiCMS, thus better serving the operational goals of the website.
Common Questions (FAQ)
- How to display a selected article with a specific ID in a particular area of the website homepage?You can directly use it in the homepage template file
archiveDetailtags and