AnQiCMS offers excellent flexibility in content management, with the core being the close integration of content models and categories.Understanding how to specify the content model for a specific category and thereby influence the display of its documents is the key to efficient website operation.This can not only organize your website content neatly, but also diversify the front-end display methods to meet different business needs.
Understanding the relationship between content models and categories
Firstly, let us clarify the concepts of "content model" and "category" in AnQiCMS.The content model can be considered as the "skeleton" or "structure definition" of the content, which allows you to customize the fields of the content according to business requirements, for example, an "article model" may contain title, author, content, publication date, etc., while a "product model" may have product name, price, inventory, product parameters, etc.By customizing the content model, it can ensure the structured storage of content.
Categories are used to organize and classify content into a hierarchical structure. It brings together documents with similar topics or properties.In AnQiCMS, after a category is created, it must specify the content model it belongs to, and once specified, this content model is fixed and cannot be changed.This means that at the initial stage of creating a category, you have already determined the content structure that all documents under this category and its subcategories will follow.This design concept ensures consistency of content and also provides a foundation for the differentiation of front-end display.
How to specify the content model for a category
In the AnQiCMS backend, the operation process of specifying the content model for categories is very intuitive.When you enter the "Content Management" under the "Document Category" feature, whether you are adding a new top-level category or editing an existing category, the system will provide options for you to select its "Document Model".
The specific operation is: When creating a new top-level category, you will see a dropdown menu that lists all defined content models (such as the default 'Article Model' and 'Product Model', as well as any custom models).You just need to select a model that is most suitable for the classification content attribute from it.Once confirmed and saved, this category and all future subcategories added will be automatically bound to this content model, and document entry and management under this model will be based on this model.
How the content model affects document entry
The binding of categories and content models directly affects the document entry experience.When you select a category bound to a specific content model to add a new document, AnQiCMS's document editing interface will automatically load the fields preset by the content model.
For example, if you select a category bound to a "product model", the document editing interface will automatically display the "product name" (corresponding to the title field of the content model), "price", "inventory", and other product-specific fields.In addition, if other fields such as "product model", "color", "material", etc. are customized for the "content model" product model, these custom fields will also be displayed in the "other parameters" collapse box in the document editing interface, for you to fill in the corresponding information.This intelligent field loading mechanism greatly improves the efficiency and accuracy of content entry, ensuring that each document follows the preset structure.
How the content model affects the display of documents (template level)
The association of categories and content models will ultimately be reflected in the document display on the website's frontend.AnQiCMS allows you to precisely control the display style of documents for different content models through a flexible template mechanism.
First, AnQiCMS follows a set of default template naming conventions. For example, if your content model table name isarticlethen the system will try to findarticle/list.htmlAs the default template for the model classification list page,article/detail.htmlAs the default template for the document detail page below. Similarly, if it isproducta model, it will correspond toproduct/list.htmlandproduct/detail.htmlThis means that even without any additional configuration, AnQiCMS can automatically match and load the corresponding general template according to the content model.
However, the strength of AnQiCMS lies in its high degree of customization. You can customize templates at multiple levels:
Category customization template:In the document classification editing interface, you can specify a "category template" and a "document template" for a specific category.
- category templateIt will affect the list page layout of the category itself, for example, you can make the list page of the "News Center" category and the list page of the "Product Exhibition" category have different styles.
- Document TemplateIt will affect the layout of the detail pages of all documents in this category. For example, you can specify that all documents in the "Technical Articles" category use a template with code highlighting, while documents in the "Company News" category use a simple template.You can also check the 'Apply to subcategories' option, so that the lower-level categories will automatically inherit this setting to avoid duplicate configuration.
Document-level custom template:For individual documents, if you want it to have a unique display style, you can set the "document template" in the "publish document" interface to achieve the most granular personalized display.
Using template tags to display content model fields:This is the core embodiment of the flexibility of AnQiCMS templates. AnQiCMS provides rich template tags, allowing you to accurately call various data from the content model, including those custom fields:
- By
{% archiveDetail with name="字段名称" %}The tag, which can be directly accessed on the document detail page to obtain any field value of the document, including any custom fields you define in the content model. For example, on a product detail page, you can call the product model like this:{% archiveDetail with name="productModel" %}. - For those parameters that are not fixed in number or need to be dynamically displayed, you can use
{% archiveParams params %}Label to iterate over all custom parameters of the current document and display their names and values in a loop. This is particularly useful when displaying product specifications or additional information in articles. Code example as follows:{% archiveParams params %} {% for item in params %} <div> <span>{{item.Name}}:</span> <span>{{item.Value}}</span> </div> {% endfor %} {% endarchiveParams %} - Other such
archiveList(Document list) ,categoryDetail(Category details) tags can also retrieve and display basic data related to the model.
- By
By closely integrating the content model with categories and utilizing multi-level template customization and powerful template tags, AnQiCMS makes website content management highly structured and easy to customize.Whether it is to create product lists in bulk, publish professional articles, or display corporate news, it can ensure the consistency of data and the diversity of display.This flexible mechanism not only improves the efficiency of content operation, but also provides a solid foundation for personalized design on the website front-end, thereby better meeting user needs and search engine optimization (SEO).
Frequently Asked Questions (FAQ)
Q: Can I change the content model belonging to a category after creating it?A: Cannot. Once a content model is specified for a category and saved, the binding relationship is fixed and cannot be modified in the background.Therefore, when creating categories, please be sure to carefully select the appropriate content model.
Q: If I have not specified a custom template for a category or document, which template will AnQiCMS use to display the content?A: If no custom template is specified, AnQiCMS will automatically search for the default template file based on the table name of the content model. For example, if the content model table name is
articleThe system will default to usingarticle/list.htmlAs the list page template,article/detail.htmlAs the detail page template. This default mechanism ensures that the content can be displayed normally even if no personalized settings are made.Q: Can I display content from different content models on the same page?A: Of course you can. The template tag design of AnQiCMS allows you to specify
moduleIdA parameter that can flexibly call a document list or details from different content models. For example, in a homepage template, you can use{% archiveList archives with moduleId="1" %}Call the article list, and then use{% archiveList products with moduleId="2" %}Call product list, to achieve a mixed display of content.