How can you make the AnQi CMS navigation link automatically display products or articles under the category?

Calendar 👁️ 47

In the daily operation of AnQi CMS, how to make the navigation links automatically display the products or articles under their categories is an important aspect for improving user experience and content discoverability.By carefully configuring the background navigation settings and combining with the powerful template tag features of AnQiCMS, we can easily achieve this goal, presenting the website content in a more intelligent and dynamic way to visitors.

First, the website navigation settings are basic. In the AnQiCMS backend management interface, access the 'Website Navigation Settings' feature, where we can create and manage various types of navigation links for the website.The AnQi CMS supports various link types, including built-in links, category page links, and external links.To implement automatic display of category content in navigation, we need to set the link type of navigation items to "category page link" and select the specific category to be associated.For example, if we want to automatically display the latest articles for the "News Information" item in the navigation menu, we need to link the "News Information" navigation to the pre-set article categories in the background.Similarly, for the 'Product Display' navigation, we will link it to a product category.When a navigation link is specified as a category page link, AnQiCMS will automatically allocate aPageIdThis ID is actually the unique identifier of the selected category.

Next, the work at the template level is crucial, as it determines how content is extracted and displayed.AnQiCMS template uses Django template engine syntax and provides rich tags for dynamic data retrieval. Among them,navListThe tag is the core of building a navigation menu. This tag allows us to traverse all the navigation items configured in the background and obtain detailed information for each navigation item.

When we usenavListWhen traversing the navigation menu, each navigation item is processed as anitemobject. If thisitemrepresents a category link, then itsPageIdThe field will contain the ID of the category. At this point, we can usearchiveListthe tag, combined with thisPageIdto dynamically load articles or products under the category.archiveListTags providedcategoryIdparameter, which can be received directlyitem.PageIdAs a classification filter condition. In addition, to distinguish between articles and products,archiveListit also supportsmoduleIdparameters, for examplemoduleId="1"usually used in article models, andmoduleId="2"May be used for product models, depending on the specific settings in your backend content model. We can also uselimitThe parameter controls the number of entries displayed, for example, only displaying the latest 5 articles or products, and usingtype="list"to get a simple content list.

Let's understand this process through a specific code example.Assuming we have a navigation item called 'Our Products', it links to a product category on the backend.In the template, we may display it and the products below it in this way:

<ul>
    {% navList navList with typeId=1 %} {# 假设typeId=1是主导航 #}
    {%- for item in navList %}
    <li>
        <a href="{{ item.Link }}">{{item.Title}}</a>
        {# 检查是否有子导航,这里我们假设“我们的产品”下直接显示产品 #}
        {% if item.PageId > 0 %} {# 只有当item是一个分类链接时才尝试获取内容 #}
            {% archiveList products with type="list" categoryId=item.PageId limit="8" moduleId="2" %} {# moduleId="2"假设是产品模型ID #}
            {% if products %}
            <ul class="product-dropdown-menu">
                {% for product in products %}
                <li><a href="{{product.Link}}">{{product.Title}}</a></li>
                {% endfor %}
            </ul>
            {% endif %}
            {% endarchiveList %}
        {% endif %}
    </li>
    {% endfor %}
    {% endnavList %}
</ul>

This example shows how to check in the main navigation loop whether the current navigation item corresponds to a category (item.PageId > 0) If so, usearchiveListthe label, to mark the current navigation item'sPageIdascategoryId, specifymoduleIdFor product model ID, and limit the display quantity, thus automatically listing the products under the category in the navigation dropdown menu.

Further, if your navigation design includes multi-level structures, such as the first-level navigation being "Product Center", with specific "Product Category A" and "Product Category B" as the second-level navigation, and products are directly displayed under these second-level categories, then you can useitem.NavListHandle the second-level navigation and apply it again in the loop of the second-level navigationarchiveListTags. You can even combine them.categoryListLabel, first determine if the navigation item has subcategories, if it does, display the subcategories, if not, directly display the articles or products under the current category, which provides great convenience for building flexible and variable navigation structures.

<ul>
    {% navList navList with typeId=1 %}
    {%- for item in navList %}
    <li>
        <a href="{{ item.Link }}">{{item.Title}}</a>
        {%- if item.NavList %} {# 如果有二级导航 #}
        <ul class="nav-menu-child">
            {%- for inner in item.NavList %}
            <li>
                <a href="{{ inner.Link }}">{{inner.Title}}</a>
                {% if inner.PageId > 0 %}
                    {# 在二级导航下,先尝试显示其子分类,如果没有子分类,则显示产品 #}
                    {% categoryList subCategories with parentId=inner.PageId %}
                    {% if subCategories %} {# 如果有子分类,显示子分类 #}
                    <ul>
                        {% for subCat in subCategories %}
                        <li><a href="{{ subCat.Link }}">{{subCat.Title}}</a></li>
                        {% endfor %}
                    </ul>
                    {% else %} {# 如果没有子分类,显示当前二级分类下的产品 #}
                        {% archiveList products with type="list" categoryId=inner.PageId limit="5" moduleId="2" %}
                        {% if products %}
                        <ul class="nav-menu-child-products">
                            {% for product in products %}
                            <li><a href="{{product.Link}}">{{product.Title}}</a></li>
                            {% endfor %}
                        </ul>
                        {% endif %}
                        {% endarchiveList %}
                    {% endif %}
                    {% endcategoryList %}
                {% endif %}
            </li>
            {% endfor %}
        </ul>
        {% endif %}
    </li>
    {% endfor %}
    {% endnavList %}
</ul>

By this method, AnQiCMS allows website operators to flexibly display products or articles under categories in the navigation menu according to actual needs, greatly improving the efficiency of website content presentation and user browsing experience. The key is to understand the association between the background navigation and categories, and to make good use of itnavList/archiveListandcategoryListThese core template tags.


Frequently Asked Questions (FAQ)

1. My navigation link shows categories, but does not automatically list articles or products. Where should I check?First, make sure that your navigation item is correctly set to "Category Page Link" in the "Website Navigation Settings" backend, and that you have selected a category that actually exists and contains content. Secondly, check the template code, confirm that you are innavListLoop internally usedarchiveListthe tags, andcategoryIdParameters are correctly bound to the navigation itemPageIdfor examplecategoryId=item.PageIdorcategoryId=inner.PageId). Also, make suremoduleIdThe parameter matches the model ID of the content type you want to display (article or product), and there is indeed published content in this category.

2. I want to display specific types of articles in the navigation (such as only displaying 'Hot Articles'), rather than all articles under categories, can AnQiCMS do this?Yes.archiveListTags providedflagParameter, you can use this parameter to filter articles with specific recommendation attributes. For example,

Related articles

How to use the `navList` tag to implement a dropdown menu effect in AnQi CMS navigation?

Building an efficient and user-friendly website navigation in Anqi CMS is a key factor in improving user experience.Especially for content-rich websites, dropdown menus can help users quickly locate the information they need while keeping the page neat.AnQi CMS provides a powerful `navList` tag, allowing website operators to flexibly implement this effect in templates.

2025-11-06

How to call custom navigation categories in the AnQi CMS template using the `navList` tag?

As a website operator who deeply understands the operation of AnQi CMS, I know that a clear and efficient navigation system is crucial for user experience and website SEO.In Anqi CMS, the `navList` tag is the core tool for building flexible and versatile navigation menus.It can not only help you display the standard top navigation, but also allow you to easily call and customize various navigation categories to meet the diverse layout needs of the website, such as footer navigation, sidebar navigation, and even context navigation for specific pages.

2025-11-06

How many levels of sub-menus does the Anqi CMS navigation list support?

As an experienced website operator who has a deep understanding and rich experience with AnQiCMS, I know the importance of the navigation system for user experience and website structure.Under the AnQiCMS framework, we can build clear and efficient website navigation to meet various operational needs.About the level of sub-menu support for the AnQi CMS navigation list, I can provide a detailed explanation.

2025-11-06

How to adjust the display order of Anqi CMS navigation links?

HelloAs an experienced CMS website operation manager, I fully understand the importance of website navigation for user experience and information architecture.Clear and logical navigation not only helps users quickly find the content they need, but also improves the overall SEO performance of the website.Next, I will give you a detailed introduction on how to adjust the display order of navigation links in AnQiCMS.In AnQiCMS, the display order of navigation links is mainly adjusted through the "Navigation Settings" function in the backend.

2025-11-06

What will happen if the custom template pointed to by the AnQi CMS navigation link does not exist?

As a website operator who deeply understands the operation of Anqi CMS, I am well aware of the importance of content presentation and user experience.In Anqi CMS, navigation links are the key paths for users to explore the website, and the templates behind them are the foundation for determining whether the content can be displayed correctly.When a navigation link points to a custom template that does not exist, it is not just a simple file missing, but also a major challenge to user experience and website professionalism.

2025-11-06

Under multi-site management, is the Anqi CMS website navigation setting independent?

**AnQiCMS multi-site management, independent analysis of website navigation settings** In the multi-site management architecture of AnQi Content Management System (AnQiCMS), the website navigation settings are highly independent.This independence is a core feature established in the initial design of AnQiCMS to meet the needs of enterprises and operators who have multiple brands, sub-sites, or require content branch management.

2025-11-06

How does the Anqi CMS navigation setting affect the website's SEO?

As an experienced website operator who has been deeply involved in AnQiCMS for many years, I know that navigation settings are crucial for the SEO of a website.A well-planned and configured website navigation can not only effectively guide users, but also profoundly affect the search engine's crawling, understanding, and ranking of the website's content.Anqi CMS was designed with SEO-friendliness in mind, its navigation settings function provides a variety of options, allowing operators to flexibly build a strong SEO foundation for the website.

2025-11-06

How can navigation descriptions optimize the user experience of the Anqi CMS website?

As an expert in AnQiCMS website operation, I know that every detail can affect the user's website experience.In the era of information explosion, users' expectations of websites are getting higher and higher. They not only hope for rich content but also require efficiency and comfort in obtaining information.Among them, the navigation system acts as the first bridge for users to interact with the website content, and its design and optimization are crucial.Our AnQi CMS provides powerful tools that allow us to finely tune every aspect of navigation, especially by enhancing user experience through navigation descriptions.

2025-11-06