As an experienced website operations expert, I know that the flexible use of templates in AnQiCMS is the key to improving website operation efficiency and user experience.When facing the need to dynamically display content model information, such as the Chinese title of the current content model, choosing the correct label field is particularly important.Today, let's delve into how to accurately display the Chinese title of the current content model in the Anqi CMS template.
Unlock Content Model Title:moduleDetailCore Field of Tag
The answer is when you want to display the Chinese title of the current content model in the Anqi CMS templatemoduleDetailTagsTitleFieldThis field is specifically used to store and display the Chinese name set for the content model by the user in the background.
AnQi CMS is known for its flexible content model management, allowing you to customize various types of content models such as “news articles”, “product showcases”, “case shares”, and more. Each content model has a clear and easily understandable Chinese title,TitleThe field is the bridge carrying this information.
TitleThe way to use the field
Used in the templatemoduleDetailLabel and fetchTitleThe field is very intuitive.If you are currently on a page context of a content model (such as the homepage or list page of the content model), you just need to call it, and the system will automatically recognize and display the title of the current model.
Here is the basic calling method:
{# 直接输出当前内容模型的中文标题 #}
<h1>{% moduleDetail with name="Title" %}</h1>
This writing is very concise, it will directly associate the current page with the content model.Titleand output the field value to<h1>the tag.
If you need to store the title in a variable for subsequent logical judgments or concatenation, you can do it like this:
{# 将当前内容模型的中文标题赋值给一个变量 #}
{% moduleDetail currentModelTitle with name="Title" %}
<p>欢迎来到 {{ currentModelTitle }} 专区!</p>
In this case,currentModelTitleThe variable will contain the Chinese title of the current content model, and you can refer to it multiple times as needed.
Deep understandingmoduleDetailLabel and its parameters
moduleDetailLabels can not only obtainTitleIt also provides various parameters, allowing you to more flexibly obtain and display various information of the content model.
nameParameters:This is the most core parameter, used to specify which specific field's information of the content model you want to obtain. BesidesTitle(Model title) there are also commonly used:Name:Model name (usually the unique identifier of the model in the system, sometimes also used for display, butTitlemore focused on external display).Link:Content model link address, convenient for you to create jump links in the template.Description:Content model summary or description.Id:Content model unique ID.TableNameThe table name of the content model in the database (usually used for development and debugging).
idParameters:If you are not in the page context of a specific content model but want to geta specific content modelThe information, can be specified by its numeric ID. For example,id="1"Will get the information of the content model with ID 1.tokenParameters:Similar toid? ButtokenAllow you to specify the model via the URL alias of the content model. This is very useful when you have specific requirements for the URL structure.siteIdParameters:For the Security CMS that has enabled the multi-site management function, if you need to getother sitesthe content model information,siteIdSpecify it.
For example, if you want to get the link of the content model with ID 2, you can write it like this:
<a href="{% moduleDetail with name="Link" id="2" %}">查看产品模型</a>
**Reflections on Practice and Operation
When usingmoduleDetailTags, as a website operation expert, I suggest you pay attention to the following points:.
- Backend naming conventions:.Ensure that when creating or editing content models in the security CMS backend,
模型标题The name of the field is clear, accurate, and user-oriented Chinese title. This will directly affect the display effect in the template. - Context awareness:When you do not specify
idortokenwhenmoduleDetailTags will try to obtain the associated content model of the current page. Therefore, it is usually not necessary to specify an ID when calling the model home page, list page, or detail page, as it can automatically adapt. - Multi-site Strategy:If your security CMS has deployed multiple sites and you need to reference model information between different sites, be sure to use
siteIdparameters to ensure the correctness of the data source. - SEO-friendly:The title of the content model is usually used as the page title (
<title>) or H1 title, which are important elements for search engines to understand the content of the page. ThroughmoduleDetail with name="Title"The title obtained can be directly used in these locations, maintaining consistency of website content and SEO-friendliness.
Summary
MastermoduleDetailTags and theirTitleThe use of the field can make you as proficient as a fish in water in the development of AanQi CMS templates, allowing you to easily present the Chinese titles of content models in various corners of the website.This not only optimizes the user experience, but also improves the management flexibility of your website content.
Common Questions (FAQ)
Q1:moduleDetailthe tag inTitleandNamefield, what are the differences?
A1: TitleThe field usually refers to the settings you make for the content model in the background,The displayed, more descriptive Chinese titlewhich is the main name that users see on the front-end page. WhileNamethe field is more focused onthe unique identification name of the model within the system,in URL alias or some internal logic use. Although they are sometimes the same, the field is more accurate when displaying the model title in the template.Titlefield is more accurate.
Q2: How can I display the title of a specific content model if I am not on the page of the content model (for example, on the homepage)?
A2:You can useidortokenParameter to specify the specific content model. For example, if you want to display the content model with ID5The title of the content model, regardless of which page you are on, you can call it like this:{% moduleDetail specificModelTitle with name="Title" id="5" %}{{ specificModelTitle }}If you know its URL alias, you can also usetokenParameter.
Q3:moduleDetailTags are not specified in pages without a content model context (such as custom static pages)idortokenWhat will happen?
A3:If the current page does not associate with any content model, and you have notidortokenspecified explicitly, thenmoduleDetailThe label may not be able to retrieve data and will return an empty value or display no content.Therefore, it is best to explicitly specify the model ID or alias you want to retrieve on these pages to ensure the correct display of content.