When a content model has custom fields (such as `author`), how can these model-specific custom fields be called in the `archiveDetail` tag?
Unlock the charm of custom field customization in AnQi CMS content model:archiveDetailAdvanced application of tags
As an experienced website operations expert, I am well aware of the importance of a flexible content management system for improving operational efficiency and achieving personalized content display.AnQiCMS (AnQiCMS) excels in this aspect with its efficient architecture based on the Go language and its excellent customizability.One of its core highlights is the "flexible content model" feature, which allows us to create dedicated fields for different types of content according to specific business needs, greatly broadening the possibilities of content presentation.
However, having these powerful custom fields is just the first step.How to present these unique data of the model accurately and elegantly on the detail page of the website front-end is a concern for many operators.authorField), how to use it in AnQi CMS'sarchiveDetailTags to call and display these unique field information.
Content Model: The Foundation of Anqi CMS Flexible Content Architecture
Before delving into the technical details, let's quickly review the content model of Anqi CMS.In AnQi CMS backend, you can easily add additional custom fields for built-in models such as 'Articles', 'Products', or create new content models.author)","Source(source)","Editor in Charge(editor)” fields.}
In the "Content Model Usage Help", you will find that each custom field has a "call field" setting when created, which is usually an identifier consisting of English lowercase letters, such as the one we mentionedauthor. This 'call field' is the key we use to refer to the custom data in the front-end template.
archiveDetailLabel: The core of the data center of the content detail page.
When a user visits a specific article or product detail page, Anqi CMS willarchiveDetailTag to load and display all relevant data for the page.This tag is the core of the content detail page, it can not only obtain the basic information such as the title, content, and publication time of the article, but is also the channel we use to access the custom fields of the model.
The AnQi CMS template engine uses a syntax similar to Django, making data calls both intuitive and powerful.We mainly have two practical and efficient methods for calling custom fields.
Method one: Direct accessarchiveObject, simple and intuitive
In the template file of the document detail page (usually{模型table}/detail.htmlIn this case, AnQi CMS will intelligently aggregate all data of the current document, including built-in fields and fields you customize, into a namedarchiveThe global variable is. This means that once you enter a document's detail page, thisarchivevariable carries all the information of the document.
Therefore, to call a namedauthorThe custom field, the most direct and simplest way is to use dot notation, as if accessing the properties of an object:
<p>作者:{{ archive.author }}</p>
here,archiveIs the object of the current document, and.authorIt directly points to what you have defined in the content modelauthorThe value of the custom field. This method is widely used in daily template development due to its conciseness
Method two: througharchiveDetailExplicitly call the tag, flexible and accurate
Although direct accessarchiveObjects are very convenient, but AnQi CMS also provides a more explicit way to go througharchiveDetailThe method to label to get the value of a single custom field.This method is particularly suitable for cases where you need to obtain a specific custom field from a non-current document (such as through ID specification) or in certain specific context scenarios where you want to have more explicit control over the source of data acquisition.
Its basic usage is to utilizearchiveDetaillabel'snameThe parameter, specifying the name of the 'call field' of the custom field you want to retrieve:
<p>作者:{% archiveDetail with name="author" %}</p>
If you want to store the obtained value in a temporary variable for subsequent processing, you can also do it like this:
{% archiveDetail docAuthor with name="author" %}
<p>文档作者:{{ docAuthor }}</p>
This method provides greater flexibility, allowing you to precisely control the source and destination of each data call.
Method three: dynamically traverse all custom fields to meet various demands.
Sometimes, you may want to dynamically display all custom fields, especially when the content model fields may change frequently, or when you want to create a universal detail page template without needing to know all the custom field names in advance. At this point,archiveParamsThe tag comes in handy. It can retrieve all custom parameters of a specified document and return them as an array, allowing you to easily iterate over them.
Here's how to combinearchiveParamsTags andforLoop to display all custom field examples:
<h3>更多文档参数:</h3>
<div>
{% archiveParams params %}
{% for item in params %}
<p>{{ item.Name }}:<span>{{ item.Value }}</span></p>
{% endfor %}
{% endarchiveParams %}
</div>
In this example,archiveParamsTags wrap all custom fields of the current document into an array namedparams(default is sorted). ThroughforLoop through thisparamsarray,item.NameIt will display the custom field name set in the background (usually the Chinese display name), anditem.ValueThis field will display specific content. This is very useful for creating highly dynamic and configurable detail page templates.
Practice exercise: Author information on the article detail page.
Let's go through a simple practical case to demonstrate how to elegantly display a custom 'author' field on the article detail page.
Assuming we have added a "call field" for the "article model" namedauthorcustom field. In yourtemplate/default/article/detail.htmlIn the template (or any custom article detail template) you can lay out like this:
”`twig {% extends ‘base.html’ %} {# Inherit base layout, assuming it exists #}
{% block content %}
<h1>{{ archive.Title }}</h1>
<div class="meta-info">
<span>发布于:{{ stampToDate(archive.CreatedTime, "2006年01月02日") }}</span>
{# 调用自定义作者字段 #}
{% if archive.author %}
<span>作者:<span class="author-name">{{ archive.author }}</span></span>
Related articles
How to combine the `archiveList` tag to filter and display the document list of a specific content model based on `moduleId`?
## AnQiCMS Content Model Deep Guide: How to Use `archiveList` to Precisely Filter Document Lists As a veteran in website operation for many years, I deeply understand the importance of a flexible and efficient content management system for a corporate website.AnQiCMS with its efficient architecture based on the Go language and highly customizable features, provides us with strong support in the content management field.
2025-11-07The `moduleDetail` tag is available on non-model related pages (such as the homepage)? How to safely obtain and use model information?
AnQiCMS (AnQiCMS) provides great convenience for website operators with its flexible content model and powerful template tag system.However, in practice, we often encounter a question: whether a tag like `moduleDetail`, which is usually used to obtain information about a specific content model, is still available on pages such as the homepage of a website that is not related to the model.How can it be used safely and effectively to obtain the required model information?As an experienced website operations expert, I will take you deep into this topic.
2025-11-07I want to display a specific icon or style in the template based on the content model's ID, what information can the `moduleDetail` tag provide to assist in the implementation?
The secret manual of AnQi CMS template customization: Skillfully use the `moduleDetail` tag to make different content models shine with unique charm In today's content-driven digital world, the appeal of a website does not only come from the quality of its content, but also from the exquisite form of its presentation and the smooth user experience.An enterprise CMS knows this, it endows operators with high flexibility with its powerful content model features, allowing them to create diversified content structures such as articles, products, events, etc. according to different business needs.
2025-11-07The `moduleDetail` tag retrieves the model link (`Link`) - is it an absolute path or a relative path, and does it support customization?
## AanQi CMS `moduleDetail` tag: Is the model link path absolute or relative?The comprehensive analysis of the custom mystery As an experienced website operations expert, I am well aware that the subtle details of content presentation in every CMS system may have a profound impact on the website's SEO performance and user experience.AnQiCMS (AnQiCMS) leverages its efficient Go language genetics and enterprise-level positioning, also showing its unique strengths in URL structure management.Today, let's delve deeply into a problem that often arises in template development and content operations
2025-11-07What is the collaboration or difference between the `archiveParams` tag and the `moduleDetail` tag in obtaining custom field information of the content model?
Today, with the increasing diversity of digital content, a flexible content management system (CMS) is undoubtedly the key to improving efficiency and achieving personalized display for enterprises and self-media operators.AnQiCMS (AnQiCMS) with its powerful content model function enables users to deeply customize the content structure according to their own business needs.However, when we delve into the template level, trying to retrieve this customized data, we may encounter some questions: `archiveParams` tag and `moduleDetail` tag
2025-11-07Can I define different types of 'recommendation attributes' for different content models (such as 'top news' for article models and 'new product' for product models)?
As an experienced website operations expert, I know that accurately recommending different types of content in content management is the key to improving user experience and operational efficiency.AnQi CMS, with its flexible content model design, indeed provides us with powerful content organization capabilities.And regarding the differentiated definition of 'recommended attributes', this embodies some exquisite operational strategies and technical implementation methods, which are worthy of in-depth exploration.### AnQi CMS: The Flexible Application of Content Model and "Recommended Attributes" Many operators will have a question when they first contact AnQi CMS
2025-11-07How to dynamically judge whether a custom field of a content model is set as required in the template?
Anqi CMS is an efficient and flexible content management system, its powerful content model customization function indeed brings great convenience to enterprises and operators.In daily content operation, we often add various custom fields for different content models (such as articles, products, events, etc.) according to business needs.These fields are some optional, some are required to be filled in, that is, 'mandatory items'.
2025-11-07Does the `moduleDetail` tag provide fields to retrieve the model creation time or update time to achieve more refined template display?
As an experienced website operations expert, I fully understand that the precise control and display of time dimension information in content management systems is crucial for website operations and user experience.Whether it is the publication time of the article or the last update time of the content, it can convey important information to the reader and also have a positive impact on search engine optimization (SEO).
2025-11-07