As an experienced website operations expert, I know that the flexible use of templates in AnQiCMS (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 template,moduleDetaillabel'sTitlefieldThis field is specifically used to store and display the Chinese name set for this content model by the user in the background.

AnQi CMS is known for its flexible content model management, you can customize various types of content models such as "news articles", "product displays", "case sharing", etc. Each content model has a clear, easy-to-understand Chinese title, andTitleThe field is the bridge that carries this information.

TitleThe way of using the field.

Using the templatemoduleDetailLabel and obtain.TitleThe field is very intuitive. If you are currently in the context of a content model page (such as the homepage or list page of a 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 style is very concise, it will directly associate the content model of the current pageTitleoutput the field value to<h1>in 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 reference it multiple times as needed.

Deep understandingmoduleDetailLabel and its parameters

moduleDetailLabels can not only retrieve.TitleIt also provides various parameters to allow you to more flexibly obtain and display the various information items of the content model.

  • nameparameters:This is the most core parameter, used to specify which specific field of the content model you want to obtain information about. In addition, there are also:Title(Model title) and other commonly used ones:

    • Name: Model name (usually the unique identifier of the model in the system, sometimes also used for display, butTitlemore focused on external display).
    • LinkThe link address of the content model, convenient for you to create jump links in the template.
    • DescriptionThe introduction or description of the content model.
    • IdThe unique ID of the content model.
    • TableNameThe table name of the content model in the database (usually used for development debugging).
  • idparameters:If you are not in the page context of a specific content model but want to obtaina specific content modelThe information can be specified by its numeric ID. For example,id="1"The information of the content model with ID 1 will be retrieved.

  • tokenparameters:Similar toidHowevertokenAllow you to specify the model through the URL alias of the content model. This is very useful when you have specific requirements for the URL structure.

  • siteIdparameters:For the safe CMS with multi-site management enabled, if you need to obtainother sitesthe content model information, you can usesiteIdspecify.

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>

**Practice and Operation Thinking

While usingmoduleDetailWhen labeling, as a website operations expert, I suggest you pay attention to the following points:

  1. Background naming conventions:Ensure that when creating or editing content models in the Anqi CMS background,模型标题The field name entered should be clear, accurate, and user-oriented. This will directly affect the display effect in the template.
  2. Context-aware:When you do not specifyidortokenparameters,moduleDetailThe tag attempts to obtain the content model associated with the current page. Therefore, when calling the model homepage, list page, or detail page, it is usually not necessary to specify an ID extra, it can automatically adapt.
  3. Multi-site strategy:If your CMS has multiple sites deployed and you need to reference model information between different sites, be sure to make use ofsiteIdparameters to ensure the correctness of the data source.
  4. SEO friendly:The title of the content model is usually used for page titles (<title>tags) or H1 titles, which are important elements for search engines to understand the content. BymoduleDetail with name="Title"The title obtained can be directly used in these locations, maintaining consistency and SEO-friendliness of the website content.

Summary

MastermoduleDetailtags and theirTitleThe use of fields can make you feel at ease in the development of Anqi CMS templates, easily displaying the Chinese titles of content models in all corners of the website.This optimizes the user experience and improves the management flexibility of your website content.


Frequently Asked Questions (FAQ)

Q1:moduleDetailin the labelTitleandNamefields?

A1: TitleA field usually refers to the one you set up in the backend for the content model,Display the more descriptive Chinese titleIt is the main name that users see on the front-end page. AndNameThe field focuses more onThe unique identification name of the model within the systemUsed in URL aliases or some internal logic. Although they may be the same sometimes, the field is more accurate when displaying the model title in templates.Titlefield is more accurate.

Q2: If I am not on the content model page (such as the homepage), but want to display the title of a specific content model, what should I do?

A2:You can use it toidortokenSpecify the specific content model. For example, if you want to display the content model with ID5The title of the content model can be called in any page:{% moduleDetail specificModelTitle with name="Title" id="5" %}{{ specificModelTitle }}If you know its URL alias, you can also usetokenParameter.

Q3:moduleDetailThe tag does not specify in a page without content model context (such as custom static pages)idortokenWhat will happen?

A3:If the current page is not associated with any content model and you have not passedidortokenspecify explicitly, thenmoduleDetailThe label may not be able to retrieve data and will return an empty value or not display any content.Therefore, it is best to specify the model ID or alias you want to retrieve on these pages to ensure the correct display of content.