As an experienced website operations expert, I am well aware that accurately calling and displaying content model details in a flexible and efficient content management system like AnQiCMS is crucial for building a feature-rich, excellent user experience website.AnQi CMS, with its powerful custom content model capabilities, allows us to flexibly build data structures according to various business needs (whether it's articles, products, or event pages).moduleDetailHow tags support us in specifying and retrieving the details of the desired content model.

Deep Analysis of AnQiCMSmoduleDetailTags: How to accurately obtain the content model you want?

In the template system of AnQiCMS,moduleDetailLabels play the role of obtaining detailed information about specific content models.It is not just about pulling data, but also the foundation for us to achieve highly customized content display.Imagine that your website has three different types of content models: 'Articles', 'Products', and 'Services'. Each model has its unique fields and display logic.moduleDetailTags are very useful.

To precisely tell the system which content model you want to obtain,moduleDetailLabels mainly provide two key parameters:idandtoken. In addition, if you are operating in a multi-site environment,siteIdParameters can be put to use.

1. By model ID (id) to specify the model to be retrieved.

The most direct and accurate way is to use the unique identifier of the content model—idSpecify it.Each content model created in the AnQiCMS backend will have a numeric ID automatically generated by the system.moduleDetailLabel.

For example, if you want to get the model details of the ID 1 (usually the default article model), you can use it like this:

<div>文章模型名称:{% moduleDetail with name="Title" id="1" %}</div>

Here,id="1"Tell exactlymoduleDetailFind the content model with ID 1 by tag,name="Title"Retrieve the name of the model and display it. This method is suitable when you have a clear understanding of the model ID, or need to hardcode a specific model in the template.

2. Through model URL alias (token) to specify the model to be retrieved.

In addition to the numeric ID, AnQiCMS also allows you to set a SEO-friendly URL alias for the content model,token.This alias is usually a combination of lowercase letters of the model, such as “article” or “product”.tokenParameters make it very convenient.

Assuming your product model URL alias is “product”, if you want to get its link, you can write it like this:

<div>产品模型链接:{% moduleDetail with name="Link" token="product" %}</div>

UsetokenThe advantage is that, even if the internal ID of the model changes, as long as the URL alias remains the same, your template code will still work normally, which brings convenience to the maintenance of the template.

3. Cross-site Model Information (siteId)

One of the highlights of AnQiCMS is its support for multi-site management, which means you can operate multiple independent websites within a single system.In certain advanced application scenarios, you may need to call the information of the content model created by another site in the template of the current site.siteIdthe parameter takes effect.

If you have a sub-site with ID 2 and you want to get the model name with ID 3 in that site, you can do it like this:

<div>子站点模型名称:{% moduleDetail with name="Title" id="3" siteId="2" %}</div>

It is worth noting that,siteIdGenerally, it is only necessary to explicitly specify in a multi-site environment. By default,moduleDetailThe tag will automatically obtain the current site's content model information, so if you only manage one site or only call the model of the current site, you can omit this parameter.

4. Obtain Specific Model Properties (name)

Once you specify which content model you want to obtain, the next step is to determine which part of the model's information you want to display. This is achieved bynameparameters.moduleDetailTag supports retrieving various built-in properties of content models, including but not limited to:

  • Id: The numerical ID of the model.
  • Title: The display name of the model in the background (e.g., “Article”, “Product”).
  • Name【en】Model's English name (usually similar to token, but may be used for internal identification in some contexts).
  • Keywords【en】Keywords at the model level.
  • Description【en】Brief introduction at the model level.
  • Link【en】Home page link of the model.
  • TableName【en】The table name corresponding to the model in the database (usually for developer reference).

【en】You can selectively display these properties as needed. If not specifiednameParameter, or asmoduleDetailAssigned as a variable, you can obtain the entire model object and then access its properties through dot notation.

For example, assign the entire model object to a variable and display its introduction:

{% moduleDetail articleModel with id="1" %}
<div>文章模型简介:{{ articleModel.Description }}</div>

In short,moduleDetailTags are a powerful tool in the development of AnQiCMS templates, giving developers the ability to accurately retrieve and display metadata of content models. By using them flexibly,id/tokenandsiteIdParameters, you can easily navigate the calling logic of the content model, combiningnameRetrieve the required properties to build highly dynamic and customizable web pages.Mastering the use of these parameters will greatly enhance your efficiency and flexibility in AnQiCMS content operation and template creation.


Common Questions (FAQ)

  1. moduleDetailTags andarchiveDetailWhat is the difference between tags?

    • moduleDetailused to obtainthe content model itselfThe details, such as the name, summary, or link of the 'article model'. It focuses on the metadata of content structure types.
    • archiveDetailis used to obtaina specific documentThe details, such as the title, content, and publication time of an article. It focuses on the specific content entities under the model. Simply put,moduleDetailThe obtained is a description of the type 'article', andarchiveDetailThe content of the specific article 'Latest News about AnQiCMS'.
  2. moduleDetailCan the tag get the list of all content models?

    • No.moduleDetailThe tag was designed from the beginning to be used forsingleThe detailed information of the content model. If you need to retrieve the list of all content models or traverse them, you usually need to go through other specialized tags (such as those that may exist)moduleListAlthough the tag is not directly displayed in the provided document, AnQiCMS design usually provides a similar function) or process it at the controller layer.moduleDetailThe essence lies in 'details' rather than 'list'.
  3. If I don't know the model'sidortoken, how should I look for it?

    • You can view and manage all created content models by logging into the backend management interface of AnQiCMS, under the 'Content Management' section and the 'Content Model' feature.Each model will clearly display its ID and URL alias (token).This is the most direct and reliable way of searching.