How to dynamically display the website navigation menu in Anqi CMS, including secondary or multi-level dropdown menus?

Calendar 👁️ 69

In website operation, a clear and intuitive navigation menu is the cornerstone of user experience.A well-designed navigation system, not only helps visitors quickly find the information they need, but also effectively guides them through the browsing path within the website, which has a significant impact on the website's usability and SEO performance.AnQi CMS understands its importance and provides a flexible and powerful navigation management function, allowing you to easily implement dynamic, multi-level navigation menus without writing complex code.

Next, we will explore how to build and manage these dynamic navigation menus in Anqi CMS, including how to implement navigation with secondary and even deeper dropdown effects.

Backend configuration: build the navigation menu skeleton

The navigation menu management of AnQi CMS is located in the back-end "Backend settings" module, click "Navigation settingsEnter here. This is where you define and organize all the website navigation.

1. Manage navigation categories: Categorize your menu.

First, you can define different navigation categories to meet the menu needs of different areas of the website.By default, the system will provide a "default navigation" category.Customize navigation categories”Function, easily add new categories, such as "Footer Navigation" or "Sidebar Navigation". Each category has a unique ID, which is used when calling the front-end template.

2. Add and organize navigation links: Create first and second-level menus

Under the navigation category you choose, you can start adding specific navigation links. Anqi CMS supports it natively.Two-level navigationThis means that each main menu item can contain a layer of dropdown menu.

  • Create a first-level menu:When adding navigation links, select “Parent navigationSet to 'Top Navigation' to create a main menu item.You can fill in the "Display Name", "Subheading Name" (if your design requires dual titles) and "Navigation Description".
  • Create a secondary menu:To create a dropdown menu, simply add a new link and set the "Parent navigationSpecify the top-level menu item you want it to belong to. This way, the newly created link will become a submenu of the top-level menu.

3. Choose the appropriate link type: Connect your content

AnQi CMS offers a variety of link types, allowing you to flexibly connect the navigation menu to various parts of the website:

  • Built-in links:Contains the "Home Link
  • Category page links:You can directly select any existing 'document category' or 'single page' as a navigation link on the website.For example, you can link to the "About Us" page or a list page of a product category.
  • External links:Allow you to input any external URL, whether it is an internal page or an external website, it can be easily integrated into your navigation.This is very useful for guiding users to partner websites or specific promotional pages.

4. Adjust display order: Arrange menu position

Each navigation link can be set to have a 'display order' value, the smaller the number, the closer the link is displayed in the menu.By adjusting these numbers, you can precisely control the arrangement position of menu items.

Front-end implementation: The magic in the template

In the Anqi CMS template file, dynamic generation of navigation menus mainly relies onnavListLabel. It will retrieve the navigation data you have configured from the background, and then you can use loop structures to build the HTML menu.

1. Implementation of basic navigation menu (level 1 menu)

First, in your template file (for exampleheader.htmlorbase.htmlIn it, you can usenavListtags to get navigation data. By default,typeIdis 1, corresponding to the "default navigation" category in the background. If you create other navigation categories, you need totypeIdThe parameter is set to the ID of the corresponding category.

{# 获取ID为1(默认)的导航类别下的所有导航数据 #}
{% navList navs with typeId=1 %}
<nav class="main-navigation">
    <ul>
        {%- for item in navs %} {# 遍历一级菜单项 #}
        <li {% if item.IsCurrent %}class="active"{% endif %}>
            <a href="{{ item.Link }}">{{ item.Title }}</a>
        </li>
        {% endfor %}
    </ul>
</nav>
{% endnavList %}

This code generates a simple first-level navigation menu.item.IsCurrentThe variable is very useful, it automatically determines whether the current page visited matches the navigation link, and you can use it to add highlighting to the current pageactivethe class name.

2. Implement a secondary dropdown menu

To implement a secondary dropdown menu, you need to check within the loop that iterates over the first-level menu items if the current menu item has a submenu (item.NavList). If there is, nest another one.forto loop through

Related articles

How to optimize image display in content lists and detail pages (thumbnails, multiple images, lazy loading)?

In the digital age where content is king, images on websites are not only visual decorations but also key elements in attracting users, conveying information, and enhancing brand image.However, unoptimized images may also become the culprit that slows down website loading speed, affects user experience, and even damages SEO performance.Fortunately, AnQiCMS (AnQiCMS) provides us with a comprehensive and powerful image optimization tool, allowing the website to maintain visual appeal while achieving high-performance loading.

2025-11-08

How to implement the complete information display of the content detail page in AnQi CMS (including custom fields)?

In website operation, the content detail page is the core entry for visitors to understand products or services, and the completeness of information display and user experience is crucial.AnQiCMS (AnQiCMS) takes full consideration of the flexibility and customization of content display in its design, even for various custom fields you define, they can also be presented elegantly on the content detail page.Next, we will explore how to fully display all the information of the content detail page in Anqi CMS, from the establishment of the content model to the call of the template, including those unique custom fields.### Build Content Skeleton

2025-11-08

How to filter and display specific content lists based on categories, modules, or recommended attributes?

When using AnQi CMS to manage website content, we often need to display specific content (such as articles, products) in the form of a list in different areas of the website.This may mean that we need to display the latest headline articles on the homepage, only show products from a specific series on the product category page, or recommend some popular content in the sidebar.AnQi CMS provides flexible tags, allowing us to accurately filter and display the content list we need based on various conditions such as categories, content models, or recommendation attributes.

2025-11-08

How to dynamically retrieve and display an article list through template tags in Anqi CMS?

Dynamic display of website content is one of the core elements of modern website operations, which not only enhances user experience and allows visitors to easily find the information they are interested in, but also effectively assists in search engine optimization (SEO), making the website more favored by search engines.In Anqi CMS, through the powerful template tag function, we can very flexibly obtain and display various types of article lists.The AnQi CMS template system has adopted the syntax of the Django template engine, with a natural and smooth style, making it very quick for you who are familiar with frontend development.

2025-11-08

How to create and display breadcrumb navigation to enhance user experience and page structure visibility?

In website operation, clear navigation is the key to improving user experience.When a visitor delves into the internal pages of a website, a well-designed and easy-to-understand breadcrumb navigation can effectively help them understand their current location and provide a quick way to return to the upper-level page.This not only makes the website structure clear, but also helps search engines better understand the website hierarchy, indirectly optimizing SEO.AnQiCMS (AnQiCMS) fully understands the importance of navigation and has built-in very practical breadcrumb navigation features

2025-11-08

How can AnQi CMS manage and display multilingual content to support international promotion?

Under the wave of globalization, does your website desire to reach a wider audience?Providing content in the native language for users of different languages can not only greatly enhance the user experience, but is also a key step in expanding into the international market.AnQiCMS (AnQiCMS) is well aware of this need, and from the very beginning of its design, it has made multilingual support one of its core features, making content internationalization simple and efficient. ### Content Organization and Presentation: Multi-site Collaboration and Language Package Support Anqi CMS provides a clear and efficient logic for managing multilingual content. First

2025-11-08

How to configure the display of page TDK (title, keywords, description) for search engine optimization (SEO) in Anqi CMS?

It is crucial for website operation to let search engines better understand and display our content.This configuration of page TDK (Title, Description, Keywords) plays a core role.AnQi CMS provides us with flexible and powerful TDK management functions, allowing us to accurately optimize search engine optimization according to the characteristics of different pages.Next, we will learn step by step how to configure these key TDK information in Anqi CMS.### One, Global Setting of Website Homepage TDK The website homepage is the facade

2025-11-08

How to use the pseudo-static function of Anqi CMS to optimize the display structure of URLs and improve SEO effects?

In website operation, the structure of URL (Uniform Resource Locator) has a significant impact on the SEO performance of the website.A clear, concise, and meaningful URL not only improves user experience but also helps search engines better understand and crawl web content.AnQiCMS (AnQiCMS) is well-versed in this field, providing powerful static URL features to help us easily optimize the display structure of URLs, thereby significantly enhancing SEO effects.

2025-11-08