How to display the navigation list configured in AnQi CMS and support multi-level dropdown menus?

Calendar 👁️ 65

The website navigation acts as a 'compass' for users to access the website, and its clarity and ease of use directly affect user experience and information acquisition efficiency.For a corporate website, a well-structured navigation system that supports multi-level dropdowns is essential.AnQiCMS (AnQiCMS) knows this, providing you with an intuitive and powerful backend configuration function, allowing you to easily build a layered navigation menu.

Next, we will explore how to configure the navigation list in the Anqi CMS backend and make it perfectly present a multi-level dropdown effect on the front end.


Step 1: Configure navigation on the backend - plan your menu structure

Manage website navigation, first you need to start from the Anqi CMS backend.After entering the background management interface, find and click on the "Background Settings" in the left menu bar, and then select "Navigation Settings".This is where you plan and build the navigation command center of your website.

1. Create navigation categories: define your navigation area

On the 'Navigation Settings' page, you will see a 'Navigation Category Management' area.By default, the system will have a 'default navigation' category.If you want to display different navigation content in different locations on the website (such as the top main navigation, bottom friend link area, sidebar menu, etc.), you can click "Add New Navigation Category" here to create a new category, such as "Footer Navigation" or "Sidebar Menu"。This is like putting labels on different drawers, making it convenient for you to categorize and manage links.

2. Set navigation links: build your menu items

After creating the navigation category, you can start adding specific navigation links. Click the "Add New Link" button in the "Navigation Link Settings" area at the bottom of the page.

  • display nameThis is the text displayed to the user for the navigation link on the front end, and you can fill it freely as needed.

  • Subtitle name and navigation description: If you need to display a subtitle or a brief description (such as bilingual translation or feature introduction) in addition to the main title, you can fill it in here.This information can also be called in the front-end template.

  • Link Type: AnQi CMS provides three flexible link types to meet your diverse needs:

    • Built-in linkIncluding quick options for common pages such as home links, article model homepage, product model homepage, etc.
    • Category page link: You can directly select an existing article category, product category, or single page as a navigation link.This means that when you create new categories or pages, they can be easily added to the navigation.
    • External link: If you need to link to a specific URL within the site or any external website, you can select this option and manually enter the complete URL.
  • Parent navigation: The key to implementing multi-level dropdowns.This is crucial. Anqi CMS currently supports the most.Two-level navigation linksThat is, a main menu item can contain a dropdown submenu of one level.

    • To createFirst-level navigation(Main menu item), please select 'Top-level navigation'.
    • To createSecondary dropdown menuItem, you need to select the 'parent navigation' it belongs to from the drop-down list. The system will intelligently recognize the primary navigation you previously set as an optional parent.
  • Display orderYou can set a number for each navigation link, the smaller the number, the higher the link appears in the navigation list.

After completing these settings, click "OK", your navigation link will be saved and added to the list. You can repeat this process to gradually build the complete navigation structure.


The second step: Front-end template call - making navigation vivid on the website

After the background configuration is completed, the next step is to display these carefully designed navigation lists on the website front end.AnQi CMS adopts Django template engine syntax, through concise template tags, you can call and render navigation data very flexibly.

The core navigation call tag isnavList. It can retrieve all the navigation data you configure on the back-end.

1. Call the basic structure of the navigation list

Generally, you will use it in the website templateheader.htmlorbash.htmland other common filesnavListto render the main navigation.

Here is a basicnavListLabel usage example:

{% navList navs with typeId=1 %} {# 这里的 typeId=1 对应后台的“默认导航”类别ID #}
<ul>
    {%- for item in navs %}
        <li class="{% if item.IsCurrent %}active{% endif %}">
            <a href="{{ item.Link }}">{{item.Title}}</a>
            {# 这里可以添加二级导航的逻辑 #}
        </li>
    {% endfor %}
</ul>
{% endnavList %}

In the code above:

  • {% navList navs %}: Declare the navigation list you want to call and assign its data tonavsVariable.
  • with typeId=1: Specify the navigation category with ID 1 (usually the default navigation). If you have created a 'Footer navigation' category, its ID might be 2, then usewith typeId=2.
  • {% for item in navs %}:Traversenavsarray,itemA variable represents the data of each first-level navigation link.
  • {{ item.Link }}and{{ item.Title }}: Get the URL and display name of the navigation link respectively.
  • {% if item.IsCurrent %}active{% endif %}: This is a very practical feature,IsCurrentThe property automatically determines whether the current page matches the navigation link, and returns if it matchestrue. You can use this property to add a navigation item corresponding to the current pageactiveClass, implement highlighting to enhance user experience.

2. Implement multi-level dropdown menus

To implement multi-level dropdown menus, you need to traverse the first-level navigation items (itemCheck if it contains child navigation (item.NavList). If it contains, perform another nested loop to render these child navigations.

{% navList navs with typeId=1 %}
<ul class="main-nav">
    {%- for item in navs %}
        <li class="nav-item {% if item.IsCurrent %}active{% endif %}">
            <a href="{{ item.Link }}">{{item.Title}}</a>
            {%- if item.NavList %} {# 检查当前导航项是否有子导航 #}
            <ul class="dropdown-menu"> {# 下拉菜单容器 #}
                {%- for inner in item.NavList %} {# 遍历子导航 #}
                    <li class="dropdown-item {% if inner.IsCurrent %}active{% endif %}">
                        <a href="{{ inner.Link }}">{{inner.Title}}</a>
                    </li>
                {% endfor %}
            </ul>
            {% endif %}
        </li>
    {% endfor %}
</ul>
{% endnavList %}

In this advanced example:

  • {%- if item.NavList %}: Determine the current level navigation.itemDoes it haveNavList(Sub-navigation list). Please note-Symbol, it can remove the blank lines generated by tags, making the generated HTML cleaner.
  • item.NavListIf it exists, it is also an array that contains the data of the secondary navigation items.
  • {%- for inner in item.NavList %}Nested loop traversalitem.NavListAssign the data of each sub-navigation item toinnerVariable.
  • {{ inner.Link }}and{{ inner.Title }}:Get the URL and display name of the child navigation link.

By such a structure, you can render a clear two-level dropdown menu on the front end.Of course, the specific style (CSS) needs to be written according to your website design to achieve an aesthetic visual effect.

3. UnderstandnavListLabel parameters and return fields

To use more flexiblynavListUnderstanding the supported parameters and return fields of the label is very helpful:

  • typeId(Parameter): Used to specify which navigation category's navigation list to call. For example,typeId=1may correspond to 'main navigation', whiletypeId=2may correspond to 'footer navigation'.
  • siteId(Parameter)If you have enabled the multi-site management feature and need to call data from other sites, you can specify the site ID through this parameter.
  • Returns field (each)itemorinnerEach object includes):
    • Title: The display name of the navigation item.
    • SubTitle: Subtitle of the navigation item (if set). *

Related articles

How to debug template display issues in AnQi CMS, such as using the `dump` filter to print variables?

Aqy CMS template debugging: Use the `dump` filter to easily locate display problems When building a website with Aqy CMS, we sometimes encounter situations where the template content is not displayed as expected.For example, you expect to display the article title at a certain location, but it turns out to be blank;Or the list data is incomplete, the content of a custom field is always unable to be presented correctly.These issues often confuse people, because it is clear that data has been set in the background, but for some reason the front-end does not display.If one can 'penetrate' the real content of the variables in the template, it will undoubtedly greatly improve the efficiency of solving such problems

2025-11-09

What basic conventions should the template files of Anqi CMS follow to correctly display the content structure?

In Anqi CMS, template files are the basis for presenting website content.It is not just a simple HTML file, but a set of blueprints that follow specific conventions and rules. Only by accurately adhering to these conventions can the system correctly parse, render, and display the structure of your website content.Understanding these basic conventions can help you customize and manage your website more efficiently, ensuring that content is presented in the way you expect to visitors.### The storage location and basic format of the template file Firstly, Anqi CMS has clear requirements for the storage location of template files

2025-11-09

How to correctly display and load images on the front-end page after the website enables Webp image format?

In website operation, the speed of image loading is crucial for user experience and Search Engine Optimization (SEO).WebP is a modern image format that, with its excellent compression performance, significantly reduces file size while maintaining image quality, thus greatly enhancing website loading speed.AnQiCMS (AnQiCMS) fully understands this and has built-in support for WebP image format in its system, making it easy for users to turn it on and benefit from it.However, after enabling the WebP feature, many users may be confused: how can the front-end page correctly display and load these WebP images

2025-11-09

How does Anqi CMS handle and display external links in content, such as adding the `rel="nofollow"` attribute?

In website operation, the management of external links is an indispensable part of content strategy and search engine optimization (SEO).Especially properties like `rel="nofollow"`, which tell search engines not to pass link weight to the linked page, are crucial for managing the link health of a website and avoiding potential SEO risks.AnQiCMS (AnQiCMS) provides multiple ways to handle and display external links in content, including automatically adding the `rel="nofollow"` attribute

2025-11-09

How to use the `lorem` tag to generate placeholder text in the early stages of development, and quickly preview the display effect of the template?

At the early stage of website template development, designers and developers often face a common challenge: how to effectively preview and adjust the layout, style, and responsive performance of the template without real content?If each modification requires manual input of a large amount of text to test the effect, it will undoubtedly greatly reduce development efficiency.AnQi CMS knows this pain point and provides a very convenient and efficient built-in tag called `lorem`, which can help us quickly generate placeholder text during the development stage, so that we can focus on the visual presentation of the template itself.### `lorem`

2025-11-09

How to display user group (VIP system) information in AnQiCMS to support member level display?

In today's internet world, the member system of websites and user grouping functions have become increasingly common. It not only helps operators provide differentiated services, but also is an important means to realize content monetization and enhance user stickiness.AnQi CMS knows this, therefore it has built a powerful user group management and VIP system, allowing the website to flexibly provide customized content and permissions for different user groups.How can we clearly display user group information (that is, VIP level) on the front-end page of a website built with Anqi CMS?This is actually more direct than imagined

2025-11-09

How to customize the display layout of the article detail page in AnQiCMS?

In website operation, the article detail page is not just a carrier of content, but also a key link for brand image, user experience, and SEO effect.A well-designed and logically organized detail page that can effectively increase user reading time, reduce bounce rate, and help search engines better understand and crawl content.For friends using AnQiCMS, deeply customizing the display layout of the article detail page is actually more flexible and convenient than you imagine.AnQiCMS as an efficient content management system, deeply understands the needs of content operators

2025-11-09

How to control the display of different content models (such as articles, products) on the front end?

In AnQi CMS, flexibly controlling the display methods of different content models (such as articles, products, cases, etc.) on the front end of the website is the key to improving user experience and meeting diverse business needs.The system provides a powerful and easy-to-understand mechanism that allows you to finely design and manage the presentation effect of the page according to the content type and specific needs. ### Understanding the Basic Role of Content Models Firstly, we need to understand the core position of the content model in the Anqi CMS. The content model is not only defined by the structure of the content, but also determines what data you can collect for different types of content

2025-11-09