How to build and display a multi-level product category navigation in AnQi CMS?

Calendar 👁️ 61

AnQi CMS is a powerful content management system that provides users with the ability to flexibly build and display multi-level product classification navigation.This not only helps website visitors find the products they need more easily, but also effectively improves the website's SEO performance and optimizes the user experience.Let's explore how to achieve this goal in Anqi CMS together.

Core fundamentals: Understanding the classification system of Anqi CMS

In Anqi CMS, the construction of multi-level product classification navigation is inseparable from its core functions of 'content model' and 'document classification'.

first, Content modelIt is the foundation for defining the structure of website content. If your website mainly showcases products, then there is usually a special "product model".This model can customize fields, such as product prices, inventory, brands, etc., to ensure that each product has its specific attributes.Categories are attached to specific content models.

secondly,Document CategoryIt is the framework for organizing content. In AnQi CMS, each category can have a parent category, thereby forming a clear hierarchical relationship.For example, you can create 'Electronics' as a primary category, and then create 'Smartphones', 'Computers', and other secondary categories under it. Even under 'Smartphones', you can further create 'Feature Phones' and other third-level categories.Each category not only has a name, link, description and other basic information, but can also set thumbnails, Banner images, even independent category content, all of which greatly enrich the possibilities of category display.

Build multi-level product classification navigation: backend operation

The first step in building a multi-level product classification navigation is to make detailed configurations in the Anqi CMS backend.

  1. Ensure that the product model has been created or defined thoroughly.Enter the 'Content Management' module in the background and select 'Content Model'.If you do not have a dedicated "product model" yet, you can create a new one or modify an existing model to suit the needs of product display.Ensure that the model includes all the custom fields required for the product.

  2. Create and organize product classifications.Find "Document Category" under "Content Management".

    • Add a top-level category:Click "Add new category", select the "Product model" you defined for the product, and enter the category name (for example, "Electronics").At this time, the 'parent category' remains empty, indicating that this is a top-level category.You can add a description, SEO title, keywords, and even upload a representative Banner image or thumbnail for this category.
    • Create a subcategory:Continue clicking "Add new category", select "Product Model", and choose the primary category you just created (for example, "Electronics").Enter the name of the subcategory (for example, "phone"). Continue in this manner, and you can create multi-level subcategories based on the depth of the product line.
    • Complete the category information:Be sure to pay attention to the "Other Parameters" section when creating or editing a category.
      • Custom URL:Set a concise, meaningful custom URL for categories, which is very important for SEO.
      • Category template:If certain categories require a unique layout or style, you can specify a custom template file here, for exampleproduct/list-12.htmlAmong them, 12 is the ID of this category), rather than using the default category list template.
      • Banner image/thumbnail:These images can be used for front-end navigation or classification pages, providing a more intuitive visual guidance.
      • Classification content:You can add an introductory text here for the category, which will be very helpful on the category page.

Display multi-level product category navigation: front-end template implementation

After the back-end category structure is set up, the next step is to vividly display it on the website through front-end template tags. The template engine of Anqi CMS provides powerfulcategoryListandnavListLabels, as well as flexible loop control, help us achieve this goal.

  1. UsecategoryListLabel display of classification levels categoryListTags are the core of obtaining the category list. By nesting, you can easily build multi-level navigation.

    Firstly, obtain the top-level product category:

    {% categoryList productCategories with moduleId="您的产品模型ID" parentId="0" %}
        <ul>
            {% for item in productCategories %}
                <li>
                    <a href="{{ item.Link }}">{{ item.Title }}</a>
                    {# 在这里检查是否有子分类,并继续嵌套调用 #}
                </li>
            {% endfor %}
        </ul>
    {% endcategoryList %}
    

    To implement multi-level, we can use again inside each category itemcategoryListtags to get their subcategories. Utilizeitem.HasChildrenThe attribute can determine whether the current category has subcategories, thereby deciding whether to render the next level of navigation:

    {% categoryList productCategories with moduleId="您的产品模型ID" parentId="0" %}
        <ul class="main-nav">
            {% for item in productCategories %}
                <li class="nav-item">
                    <a href="{{ item.Link }}">{{ item.Title }}</a>
                    {% if item.HasChildren %} {# 判断是否有子分类 #}
                        <ul class="sub-nav">
                            {% categoryList subCategories with parentId=item.Id %} {# 获取当前分类的子分类 #}
                                {% for subItem in subCategories %}
                                    <li class="sub-nav-item">
                                        <a href="{{ subItem.Link }}">{{ subItem.Title }}</a>
                                        {# 甚至可以在这里继续嵌套,如果您的分类层级更深 #}
                                    </li>
                                {% endfor %}
                            {% endcategoryList %}
                        </ul>
                    {% endif %}
                </li>
            {% endfor %}
        </ul>
    {% endcategoryList %}
    

    In the above code,moduleIdShould be replaced with your product model ID (usually found in the background "Content Model"),parentId="0"It represents getting all top-level categories.item.IdUsed to specify getting the subcategories of the current category.

  2. CombinenavListTag builds the main navigation.If your main navigation menu needs to be flexible to configure in the background and includes product categories, thennavListThe label would be a more suitable choice. In the background 'Background Settings' -> 'Navigation Settings', you can create a new navigation category, such as 'Product Main Navigation', and then add various product categories and set up the hierarchy.In the front-end template, you can call it like this: “`twig {% navList mainNav with typeId=“Your product main navigation category ID” %} {# Assuming your product main navigation category ID is 2 #}

    <ul class="main-menu">
        {% for navItem in mainNav %}
            <li class="menu-item {% if navItem.IsCurrent %}active{% endif %}">
                <a href="{{ navItem.Link }}">{{ navItem.Title }}</a>
                {% if navItem.NavList %} {# 检查是否有子导航项 #}
                    <ul class="submenu">
                        {% for subNavItem in navItem.NavList %}
                            <li class="submenu-item {% if subNavItem.IsCurrent %}active{% endif %}">
                                <a href="{{ subNavItem.Link }}">{{ subNavItem.Title }}</a>
                                {# 也可以在此处显示产品列表或更深层级的分类 #}
                                {% if subNavItem.PageId > 0 %} {# 如果是分类链接,PageId会大于0 #}
                                    {% categoryList subCategories with parentId=subNavItem.PageId %}
                                        {% if subCategories %}
                                            <ul class="sub-submenu">
                                                {% for thirdLevelCat in subCategories %}
                                                    <li><a href="{{ thirdLevelCat.Link }}">{{ thirdLevelCat
    

Related articles

How to display custom fields (such as author, source) of AnQi CMS documents on the front-end page?

When managing content in Anqi CMS, we often encounter the need to add more personalized data to articles, products, or pages, such as the author of the article, the source of content, or specific parameters of products, or specific attributes of event pages, etc.This additional customization information is called "custom field".The powerful content model function of AnQi CMS makes it very convenient to create and manage custom fields, and more importantly, how to accurately and beautifully present these meticulously entered custom fields on the front page of the website

2025-11-09

How to use the `tagList` tag to display the associated tag list on the article detail page?

In content operation, tags (Tags) are a very practical tool that can help us organize content more flexibly, making it convenient for readers to quickly find related topics of interest.Imagine that after a user reads an excellent article, if they can immediately see other popular topics or keywords related to that article, it will undoubtedly greatly enhance their browsing experience and encourage them to explore other content on the website.In Anqi CMS, implementing this feature is very intuitive and simple, we mainly rely on the powerful `tagList` tag to complete it.

2025-11-09

How to display the category information of the articles on the front page of AnQi CMS, including the category name and link?

In Anqi CMS, the display of article category information on the front page is a key link in content organization and user navigation.Whether it is to help users understand the context of the article or to optimize the website's SEO structure, accurate and accessible category names and links play an important role.AnQi CMS with its flexible template engine makes this task intuitive and efficient.Understanding Anqi CMS's Classification System Before delving into the display methods, we first need to know that Anqi CMS's content management system attaches great importance to the concept of 'classification'.Each document (whether it is an article

2025-11-09

How to display the publication time of articles in Anqi CMS and customize the date and time format?

When operating website content, the publication time of the article is an indispensable element.It not only helps visitors quickly understand the "freshness" of the content, but also has a positive impact on search engine optimization (SEO), as it conveys the signal that the website content is continuously updated.AnQiCMS provides great flexibility in content management, whether it is to obtain or customize the display time of published articles, it is very convenient.Next, we will explore how to flexibly display the publication time of articles in Anqi CMS

2025-11-09

How to get and display the custom Banner image group of the `categoryDetail` tag?

In website operation, configuring unique visual elements for different category pages, such as customized banner image groups, is crucial for enhancing user experience and strengthening brand recognition.AnQiCMS (AnQiCMS) leverages its flexible content management capabilities, allowing users to easily set up exclusive Banners for each category and provides intuitive template tags for conveniently displaying these contents on the frontend page.We all know that when users browse a website, the category page is a key entry point for them to explore content.

2025-11-09

How to effectively display the description (Description) and content (Content) on the front page?

In AnQi CMS, the description (Description) and content (Content) are key elements for website content organization and search engine optimization (SEO).Effectively display this information on the front page, not only providing visitors with clear navigation and in-depth information, but also helping search engines better understand the theme of the page, thereby improving the visibility of the website.Let's explore how to flexibly display the description and content of categories in the Anqi CMS front-end template together.

2025-11-09

How does the `pageList` tag in Anqi CMS display all single page lists and exclude specific pages?

AnQi CMS is a flexible and efficient content management system that provides strong support for our website operations, whether it is publishing articles, managing products, or creating various single-page applications, it shows great proficiency.Today, let's talk about a very practical skill when using Anqi CMS to manage single-page applications: how to display all single pages through the `pageList` tag while also accurately excluding specific pages that we do not want to display.In daily website operations, we often create some single-page pages such as "About Us", "Contact Information", "Privacy Policy" and so on

2025-11-09

How to retrieve and display all the detailed content of a single page, including the slide group image, using the `pageDetail` tag?

In Anqi CMS, a single page is an indispensable part of the website structure, commonly used to display 'About Us', 'Contact Information', 'Service Introduction', etc., which are relatively fixed and do not require frequent updates.For these pages, we usually want to be able to flexibly control the way content is displayed, including text, images, and even slide group images.The `pageDetail` tag is born for this, it allows us to easily retrieve and display all the detailed content of a single page.###

2025-11-09