How does AnQiCMS implement multi-level category nesting calls and document list display?

Calendar 👁️ 84

In the operation practice of AnQiCMS, flexible content organization and display is the key to attracting and retaining users.The multi-level category nesting call and dynamic display of document lists are the core embodiment of AnQiCMS giving operation personnel strong content management capabilities.By skillfully applying system template tags, we can not only build a clear website structure, but also present content accurately according to the reader's needs.

AnQiCMS classification system overview

The foundation of AnQiCMS content management lies in its flexible 'content model' and 'document classification'.The content model allows us to customize the content structure based on business needs (such as articles, products, etc.), and document classification is based on this, classifying specific content hierarchically.For example, a 'article model' can have 'news dynamics', 'technical tutorials', 'industry analysis', and other first-level categories. Each first-level category can further subdivide into second-level and third-level categories, forming a structured content system.This hierarchical organization is crucial for user navigation, content retrieval, and SEO optimization.

Implement nested hierarchical classification

AnQiCMS through its powerful template tagscategoryListmaking nested hierarchical classification intuitive and efficient.categoryListThe tag is used to retrieve the category list under the specified content model and provides rich parameters to control the call range and level.

When we need to display the navigation menu of a website or present a category tree in the sidebar,categoryListtags can help us easily achieve this. Its core lies in usingmoduleIdspecifying the content model that belongs to, and combining withparentIdThe parameter performs hierarchical traversal. For example, to get all top-level categories, we can setparentId="0". While traversing these top-level categories, each category item (item) contains aIdandHasChildrenField. We can utilizeHasChildrento determine if the current category has subcategories, if it does, then we can call it againcategoryListand use the current category'sIdas the subcategory'sparentIdThus, it can achieve infinite-level nesting.

The following is a typical code structure for implementing multi-level classification nesting calls:

{% categoryList categories with moduleId="1" parentId="0" %}
{# 这是一个一级分类的无序列表 #}
<ul>
    {% for item in categories %}
    <li>
        <a href="{{ item.Link }}">{{item.Title}}</a>
        <div>
            {% categoryList subCategories with parentId=item.Id %}
            {# 这是二级分类的无序列表 #}
            <ul>
                {% for inner1 in subCategories %}
                <li>
                    <a href="{{ inner1.Link }}">{{inner1.Title}}</a>
                    <div>
                        {% categoryList subCategories2 with parentId=inner1.Id %}
                        {# 这是三级分类的无序列表 #}
                        <ul>
                            {% for inner2 in subCategories2 %}
                            <li>
                                <a href="{{ inner2.Link }}">{{inner2.Title}}</a>
                            </li>
                            {% endfor %}
                        </ul>
                        {% endcategoryList %}
                    </div>
                </li>
                {% endfor %}
            </ul>
            {% endcategoryList %}
        </div>
    </li>
    {% endfor %}
</ul>
{% endcategoryList %}

In this code, the outermostcategoryListto get the top-level classification, followed by theforLoop through these categories. We call again within each top-level category.categoryList, usingparentId=item.IdTo get its direct subcategory. This process can be recursively nested according to the actual classification depth of the website, thus building a complete classification tree structure.item.Linkanditem.TitleUsed to generate category links and display names, ensuring the correctness of navigation and user experience.

Flexible document list display

After building a perfect classification system, how to efficiently display the document list based on these classifications is the key step. AnQiCMS providesarchiveListTag, it is a powerful content aggregator that can filter and display documents based on various conditions.

archiveListThe tag can be used in conjunction with document list retrieval.categoryIdParameters to specify only documents under a certain or several categories. It is worth noting that,archiveListit also supportschildparameter, whose default value istrueThis means it will automatically include all documents in the subcategories of the current category. If the operator only needs to display the documents of the current category itself and not include the content of its subcategories, then it canchildis set tofalse.

Here is an example of displaying a document list combined with category looping:

{% categoryList categories with moduleId="1" parentId="0" %}
<div>
    {% for item in categories %}
    <div>
        <h3><a href="{{ item.Link }}">{{item.Title}}</a></h3>
        <ul>
            {% archiveList archives with type="list" categoryId=item.Id limit="6" %}
            {% for archive in archives %}
            <li>
                <a href="{{archive.Link}}">
                    <h5>{{archive.Title}}</h5>
                    <div>{{archive.Description}}</div>
                    <div>
                        <span>{{stampToDate(archive.CreatedTime, "2006-01-02")}}</span>
                        <span>{{archive.Views}} 阅读</span>
                    </div>
                </a>
                {% if archive.Thumb %}
                <a href="{{archive.Link}}">
                    <img alt="{{archive.Title}}" src="{{archive.Thumb}}">
                </a>
                {% endif %}
            </li>
            {% empty %}
            <li>
                该分类下暂无内容
            </li>
            {% endfor %}
        {% endarchiveList %}
        </ul>
    </div>
    {% endfor %}
</div>
{% endcategoryList %}

In this example, we firstcategoryListGet the top-level category, and then in aforLoop, call for each category againarchiveList. At this point,archiveListofcategoryIdThe parameter is dynamically set to the current category'sitem.Idthereby achieving document aggregation display by category.limit="6"which limits each category to display only 6 documents,type="list"indicating a regular list display.

In addition to displaying by category,archiveListit also supports various advanced filtering and sorting features to meet more complex display requirements:

  • page display:Whentype="page"then,archiveListit will generate page data, which needs to be配合paginationLabel to render pagination navigation. This is particularly important for displaying a large number of documents, as it can improve page loading speed and user experience.
  • Recommended attributeUtilizeflagParameters, we can filter out documents with specific recommendation attributes (such as headlines, recommendations, slides, etc.) for easy highlighting on the homepage or in specific areas.
  • Sorting method:orderParameters allow us to sort in ascending or descending order based on document ID, views, and custom sorting values, ensuring that content is presented in the most relevant or most recent manner.
  • Search and filter:qParameters can be used for keyword search in the title, and custom filter parameters can be passed through URL query parameters to further refine the display content of the document list, for example, based on product features or article tags.

Summary

AnQiCMS provides a concise and powerful template tag system, offering highly flexible multi-level nested calls and document list display capabilities for website operators.From building clear website navigation to dynamically presenting content based on细分 categories, to achieving advanced content filtering and sorting, AnQiCMS empowers content operators to create high-quality, easy-to-manage, and excellent user experience website content with intuitive syntax and rich parameters.This has improved the organization efficiency of the website content, and also provided users with a more personalized and convenient content access experience.

Frequently Asked Questions

How many levels of nested category calls are supported in AnQiCMS?AnQiCMS'categoryListLabels theoretically support unlimited level category nested calls. Each callcategoryListWhen, just use the parent category's ID asparentIdThe system can obtain the sub-categories of the next level by passing the parameters.In practice, the depth of category levels is usually determined by the business logic and user experience of the website, and it is generally not recommended to have too deep levels to avoid overly complex navigation.

How to ensure that only the documents of the current category are displayed in the document list, and not the content of its subcategories?While usingarchiveListLabel to retrieve document list, if you want to display only the documents in the current category and not include the documents in the subcategories, you canchildthe parameter tofalse. For example:{% archiveList archives with type="list" categoryId=item.Id child=false limit="10" %}. By default,childparameters fortrueIt will display all the documents of the sub-categories.

Besides filtering by category, what flexible ways does AnQiCMS support for displaying document lists?AnQiCMS'archiveListTags support various flexible display methods. In addition to filtering bycategoryIdYou can also filter byflagdocuments with specific recommended attributes (such as headline, recommendation) throughorderCustom parameter sorting method (such as by browsing

Related articles

How to perform conditional judgment (if-else) and loop traversal (for) in AnQiCMS templates?

AnQiCMS (AnQiCMS) is an efficient and customizable content management system. Its template engine design philosophy is to simplify the complexity of content presentation, allowing website operators to focus on content organization and optimization.In the daily operation of websites, we often need to display content based on different conditions, or iterate through list data for dynamic rendering.AnQi CMS provides intuitive and powerful template tags, the most basic and core of which are conditional judgment (`if-else`) and loop traversal (`for`) tags.

2025-11-06

How to include common code snippets like header and footer in AnQiCMS templates?

As an experienced AnQiCMS website operator, I am well aware of the importance of website template efficiency and maintainability for daily work.A well-designed template structure that ensures consistency in the brand image of the website, improves user experience, and significantly reduces the cost of content updates and website maintenance.In AnQiCMS, reasonably introducing common code snippets, such as the website header and footer, is the key to achieving this goal.

2025-11-06

What kind of template engine syntax does AnQiCMS support and how easy is it to learn?

As an experienced CMS website operation personnel, I fully understand the importance of an efficient and easy-to-use content management system for our daily work.Among other things, the flexibility and learning curve of the template engine are directly related to the efficiency of content display and the customizability of the website.AnQiCMS on this point, has provided us with a very friendly solution. ### AnQiCMS Template Engine Syntax Parsing One of AnQiCMS's core strengths lies in the template engine syntax it adopts.

2025-11-06

What is the template file structure and naming convention of AnQiCMS?

As an experienced website operator who deeply understands the operation of AnQiCMS, I know that the foundation of content presentation lies in its flexible and standardized template system.A deep understanding of AnQiCMS template file structure and naming conventions is the key to efficient website content management, personalized display, and system stability.The detailed principles of AnQiCMS template design will be elaborated.AnQiCMS template system is designed to provide high customization and ease of use.The core lies in a clear directory structure and a set of Django-style template syntax

2025-11-06

How to add documents and set recommended attributes, SEO titles, and scheduled publishing in AnQiCMS?

As a professional who deeply understands the operation of AnQiCMS, I know that efficient content publishing and fine SEO optimization are the key to the success of the website.AnQiCMS provides intuitive and powerful tools to help us easily manage website content.This article will provide a detailed explanation of how to add new documents in AnQiCMS, focusing on how to set recommended properties, SEO titles, and scheduled publishing features to ensure your content reaches the target audience accurately and achieves better search engine performance.

2025-11-06

How to manage document categories in AnQiCMS and how to set custom fields for categories?

As a website operator who deeply understands the operation of AnQiCMS, I know the importance of content organization and personalized display for attracting and retaining users.In AnQiCMS, the management of document categories and the setting of custom fields are the core links to achieve this goal.A well-structured classification can help users quickly find the information they need, and flexible custom fields make content display more in-depth and diverse. ### Document Classification Management: Build a Clear Content Architecture In AnQiCMS, document classification is the foundation of website content organization.

2025-11-06

How to perform batch keyword replacement operations for documents in AnQiCMS backend?

As a senior practitioner who is deeply engaged in CMS content operation for enterprise safety, I know how crucial it is to efficiently update and maintain content in daily website management.AnQi CMS is not only favored for its simple and efficient architecture, but also for its powerful feature set, becoming a powerful assistant for us to improve operational efficiency.Among them, the document batch keyword replacement function is particularly prominent, which can help us unify the correction of content, ensure the timeliness and accuracy of information, and greatly reduce the burden of manual editing.

2025-11-06

What types of custom fields are supported in the AnQiCMS content model, and how do you add them?

In the operation practice of AnQi CMS, the flexible application of content models and custom fields is the key to improving website content management efficiency and achieving personalized display.As a website operator deeply familiar with AnQiCMS features, I will elaborate on the types of custom fields supported in the content model and their addition methods, helping you fully tap into the potential of AnQiCMS. AnQi CMS is dedicated to providing highly customizable content management solutions, among which 'flexible content model' is one of its core strengths.

2025-11-06