How to retrieve all **category lists and display them on the page?

📅 November 6, 2025 👁️ 109

Anqi CMS: How to retrieve and display all **category lists on the website page

As a website operator, I fully understand the importance of clear website structure for user experience and Search Engine Optimization (SEO).Categorization navigation is one of the core elements of website content organization, it not only guides users to quickly find the information they need, but also helps search engines better understand the content hierarchy of the website.AnQiCMS provides a直观 and powerful template tag system, allowing website operators to easily manage and display the classification structure of the website.

Understand the classification system of Anqi CMS

In AnQi CMS, content is organized in the form of 'categories'.Each category belongs to a specific "content model" (such as article model, product model), which makes content management more flexible and structured.To obtain the list of website categories, we first need to understand how these categories are associated with the content model, as it is often necessary to specify the content model ID when calling the category data.

applycategoryListTag to get category data

AnQi CMS template system provides a namedcategoryLista dedicated tag for retrieving and looping through the website's category data. This tag is designed to be very flexible and can be configured with parameters according to different needs (such as retrieving specific model categories, retrieving child categories, retrieving all categories, etc.). For our current requirement - retrieving all **category lists,categoryListThe key to the tag is itsparentIdParameter.

Accurately retrieve **category lists

To accurately retrieve all categories that do not belong to any superior categories, we need toparentIdthe parameter to"0"In addition, since each category in the AnQi CMS is bound to a specific content model, when retrieving **categories, we also need to specify the categories belonging tomoduleIdFor example, if we want to get the article model (usuallymoduleId="1"All **categories under this) will be specified, so the combined label will specifymoduleId="1"andparentId="0"Thus,categoryListThis label can accurately return the required **category data.

Display the **category list on the page

Once we pass throughcategoryListAfter the label gets the **category data, it can beforLoop to iterate through these data and display it on the page. Inside the loop, we can easily access various properties of each category, such as the category ID (item.Id), Title (item.Title) and link (item.Link) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assuming ) etc. The following is a specific template code example demonstrating how to retrieve the article model (assumingmoduleIdFor all **categories under 1), and display their titles and links in list form:

{# 假设要获取文章模型(moduleId="1")的所有**分类 #}
<nav class="main-category-navigation">
    <ul>
        {% categoryList categories with moduleId="1" parentId="0" %}
            {% for item in categories %}
                <li>
                    <a href="{{ item.Link }}">{{ item.Title }}</a>
                    {# 如果需要,可以根据 item.HasChildren 判断是否有子分类并决定是否加载更多内容 #}
                </li>
            {% empty %}
                <li>目前没有**分类可供显示。</li>
            {% endfor %}
        {% endcategoryList %}
    </ul>
</nav>

In this example,categoriesIs the variable name defined for the **category list. By{{ item.Link }}and{{ item.Title }}We output the access address and display name of the classification separately.{% empty %}A block is a very practical feature that displays friendly prompt information when no category data is returned, enhancing user experience.

Integrate the code into your website template.

This code can be placed at different positions in the website template according to the design requirements. For example, if this is part of the main navigation of the website, it may be included inpartial/header.htmlorbase.htmlSuch a public template file is in order to maintain consistency across all pages. If it is a sidebar category list, it can be placed inpartial/aside.htmlEmbed it directly into the page template it needs, such asindex/index.html. No matter where it is placed,categoryListthe tag ensures that the latest category data is dynamically loaded without manual update.

The importance of the content model ID

In actual operation, please ensure thatmoduleIdThe value matches the content model ID associated with the category you want to retrieve. AnQi CMS allows users to customize content models, so different websites have different content models.moduleIdMay vary. You can view and manage the 'Content Model' in the 'Content Management' menu of the Anqi CMS backend. Specify correctly.moduleIdThis is a key step to obtain an accurate classification list.

BycategoryListLabel collaborationmoduleIdandparentId="0"Parameters, AnQi CMS provides an efficient and flexible way to retrieve and display all **categories** of a website. This method not only maintains the clarity and tidiness of the website structure but also greatly enhances the discoverability and user experience of the content. As an operations manager, I know that the ease of use of the tool is the key to improving efficiency, and AnQi CMS does a very good job in this regard.

Frequently Asked Questions (FAQ)

1. How do I know about my content model?moduleIdare?

You can log in to the Anqi CMS backend, navigate to the "Content Management" menu, and then select the "Content Model".There, you will see all the defined content models and their corresponding IDs.For example, the 'Article Model' is usually ID 1, the 'Product Model' ID 2, but custom models will have their specific IDs.Be sure to use the exact numeric ID displayed here.

2. How should I modify the code if I want to display the subcategories of a **category** at the same time?

If you want to display subcategories under a **category**, you can do so in the **category**.forit again within the loopcategoryListLabel, andparentIdparameter set to the current **category'sitem.Id. For example:{% categoryList subCategories with parentId=item.Id %},then in this newsubCategoriesloop, display subcategories. This can build a multi-level navigation structure.

3. Why is my **category list not displaying any content?

There may be several reasons. First, please checkmoduleIdHave you correctly specified the model ID of the content you want to retrieve? Secondly, confirm that there is indeed a **category in the 'Content Management' -> 'Document Category' section of the AnQi CMS backend, and that the 'Parent Category' field for these categories is empty, indicating that they are **categories themselves. Finally, make sure that your template file is saved in UTF-8 encoding format and that there are no syntax errors that prevent the tags from being parsed correctly.

Related articles

How to display the detailed information (name, description, image) of a category on the category page?

As an experienced CMS website operation personnel of an enterprise, I am well aware of the core position of the classification page in the website structure and user experience.A well-designed, informative category page not only helps users quickly find the content they need, but also enhances the overall professionalism of the website through clear hierarchy and attractive visual elements, and is also crucial for search engine optimization (SEO).Today, I will elaborate on how to effectively configure and display the detailed information of category pages in Anqi CMS, including their names, descriptions, and associated images.### Enhance User Experience and SEO

2025-11-06

How to get the title and link of the previous and next articles of the current article?

As an experienced website operator familiar with AnQi CMS, I am well aware of the importance of article navigation in content management for improving user experience and optimizing website structure.When a reader is browsing an article meticulously crafted, if they can conveniently jump to the previous and next related or sequential articles, it not only extends the user's stay on the website, increases the page views, but also conveys a better internal link structure to search engines, thereby helping to improve the website's SEO performance.The AnQi CMS provides simple and powerful template tags

2025-11-06

How to dynamically generate the breadcrumb navigation path of the current page?

As an expert who deeply understands the operation of AnQiCMS, I know that a clear and easy-to-use navigation system is crucial for both website visitors and search engines.Breadcrumb Navigation is an effective tool that improves user experience and website SEO performance.It can directly display the user's current position in the website structure, helping them easily backtrack, and also provide clues for search engines about the website's hierarchical structure.

2025-11-06

How to display first and second level menus and their links in the website's main navigation?

As an experienced website operator, I am well aware of the importance of a clear and intuitive navigation system for website user experience and content discovery.AnQiCMS (AnQiCMS) with its flexible content management features, allows us to easily build navigation structures that meet various business needs.Today, I will explain in detail how to cleverly set up and display the first and second-level menus and their links in the main navigation of the website based on the powerful functions of AnQiCMS.

2025-11-06

How to display all related Tag tags on the article detail page?

As a professional who deeply understands the operation of Anqi CMS, I know that every detail of content creation and display is related to user experience and the SEO performance of the website.Properly displaying related Tag tags on the article detail page can not only help readers quickly understand the core of the article and find more related content, but also has a positive effect on search engine optimization.Below, I will elaborate on how to implement this feature on the article detail page of Anqi CMS.

2025-11-06

How to customize the display of TDK (Title, Keywords, Description) content on a page?

As a senior AnQiCMS website operations personnel, I fully understand the core role of TDK (Title, Keywords, Description) in website search engine optimization (SEO).They are not only the key for search engines to understand the content of a page, but also important factors to attract users to click.In Anqi CMS, the configuration and custom display of TDK have high flexibility, which can meet the fine-grained optimization needs of different pages.

2025-11-06

How to use if-else logic in a template to control the display of content?

In Anqi CMS template creation, flexible control of content display is the key to improving user experience and meeting diverse business needs.As an experienced website operator, I am well aware of the importance of dynamic content presentation.The AnQi CMS adopts a syntax similar to the Django template engine, which allows content operators to implement conditional judgments in templates in a straightforward manner, thereby precisely controlling which content is visible to users at what time and place.The template syntax design of AnQi CMS makes it easy for developers and content operators to get started.

2025-11-06

How to traverse an array or list and output each item on the page?

In AnQi CMS template development, effectively traversing and outputting arrays or lists is a core skill for building dynamic and rich content pages.As a senior security CMS operator, I know the importance of flexibly using template tags for content presentation.The Anqi CMS adopts a syntax similar to the Django template engine, making content looping and conditional judgments intuitive and powerful.

2025-11-06