How to call the link of category page or single page in AnQiCMS navigation list?

Calendar 👁️ 68

The Anqi CMS plays a core role in website operations, and the navigation system is a guide for users to explore the website content.A well-designed, easy-to-use navigation not only improves user experience, but is also a key factor in search engine optimization.Today, let's delve deeply into how to flexibly integrate category pages and single page links巧妙地融入到网站的导航列表之中 into the navigation list of the AnQiCMS website.

Navigation configuration: The bridge from the backend to the frontend

The navigation system of AnQiCMS is designed to be very intuitive and powerful, closely integrating the navigation configuration with the call of the front-end template.In the background management interface, under 'Background Settings' -> 'Website Navigation Settings', you will find a highly flexible navigation management module.Here, you can create different navigation categories, such as top navigation, footer navigation, or sidebar navigation, to meet the display needs of different website areas.

Under each navigation category, you can add specific navigation links. AnQiCMS offers a variety of "link types" for selection:

  • Built-in links:Including homepages, specific content models (such as articles, products) homepages, etc., these links are preset by the system.
  • Category page links:This is one of the types we are focusing on today. You can directly select the article category or product category you have created, and the system will automatically retrieve and manage the link of the category.
  • Single page link:Similarly, you can choose the independent single pages such as "About Us", "Contact Us", etc. The system will also automatically handle their links.
  • External links:Allow you to add any internal or external URLs, bringing great extensibility to the navigation system.

When you select the 'Category Page Link' or 'Single Page Link' in the background, AnQiCMS will automatically identify and bind the corresponding real URL address to this navigation item.This means, you do not need to manually enter complex categories or single-page addresses, the system will take care of everything for you.This design greatly reduces the workload of operations personnel and ensures the accuracy of the links.

Calling the navigation list in the template: the magic of the navList tag.

Once the background navigation items are configured, how can these links be presented in the frontend template? AnQiCMS provides a core template tag for this—navList. This tag helps us get the navigation data set up in the background and provide it in a structured way for template iteration.

UsenavListWhen labeling, it is usually defined like this to store navigation data:{% navList navs %}. Here,navsIt is the set of navigation items we will be operating on. If you have created multiple navigation categories in the background (such as the ID of the "top navigation" is 1, and the ID of the "footer navigation" is 2), you can access them throughtypeIdParameters are used to specify which category of navigation to call, for example{% navList navs with typeId=1 %}.

obtaining tonavsAfter the data is processed, we can then iterate through it to display each navigation item. In the loop, each navigation item will be associated with aitemThe variable represents,item.Linkanditem.TitleThat is the core information we need.item.LinkIt directly includes the URL of the category page, single page, or external link configured in the background,item.Titlewhich is the display name of the navigation item.

This is an example of a typical AnQiCMS navigation list template call, demonstrating how to handle multi-level navigation and naturally include links to category pages or single pages:

{% navList navItems with typeId=1 %} {# 假设typeId=1是您的主导航 #}
<nav class="main-navigation">
    <ul class="nav-menu">
        {% for item in navItems %}
            <li class="nav-item {% if item.IsCurrent %}active{% endif %}">
                <a href="{{ item.Link }}" title="{{ item.Title }}">{{ item.Title }}</a>
                {% if item.NavList %} {# 检查是否有子导航 #}
                    <ul class="sub-menu">
                        {% for subItem in item.NavList %}
                            <li class="sub-item {% if subItem.IsCurrent %}active{% endif %}">
                                <a href="{{ subItem.Link }}" title="{{ subItem.Title }}">{{ subItem.Title }}</a>
                            </li>
                        {% endfor %}
                    </ul>
                {% endif %}
            </li>
        {% endfor %}
    </ul>
</nav>
{% endnavList %}

In this code block:

  1. {% navList navItems with typeId=1 %}Called navigation category with ID 1 and stored all navigation items innavItemsthe variable.
  2. {% for item in navItems %}Loop through each main navigation item.
  3. {{ item.Link }}Directly output the URL configured for this navigation item in the background. Whether it is a category page, a single page, or other link types,item.Linkit will provide you with the correct address.
  4. {{ item.Title }}Display text of the navigation item.
  5. {% if item.IsCurrent %}Used to determine if the current navigation item is a link to the current page, for easy highlighting.
  6. {% if item.NavList %}Check if the current navigation item has a sub-navigation. If so, it will pass through again.forLoop through and render the sub-navigation list, treating it similarly to the main navigation item.

It is worth mentioning that if you need to display more than just links and titles in navigation, and also want to get more details about a category or a single page (such as its introduction, thumbnail, etc.), AnQiCMS also provides powerful extension capabilities. When you select "Category Page Link" or "Single Page Link" in the background, the navigation item'sitemA variable will also include oneitem.PageIdthis attribute.PageIdStored the ID of the linked category or single page. You can combinecategoryDetailorpageDetailLabel, based onitem.PageIdTo get this additional information, create richer and more dynamic navigation content. However, for the core need of simply using a 'call link', it is direct to useitem.Linkit is enough.

Summary

AnQiCMS with its intelligent backend configuration and powerful template tag system makes it extremely simple and efficient to call links to category pages or single pages in the navigation list. Operators only need to specify the link type and target content in the backend, and the frontend template passes throughnavListTags and their attributes can smoothly display these preset links on the website.This seamless design ensures the flexibility, maintainability, and good user experience of the website navigation, allowing your website content to be better discovered and browsed by users.

Frequently Asked Questions (FAQ)

Q1: Can I make a navigation item in the navigation list not just link to a category page, but also display the latest few article titles under that category? A1: Can be. You can use it in the submenu of the navigation item or in a specific area.item.PageId(If the navigation item links to a category) asarchiveListlabel'scategoryIdParameters to call the latest articles under this category. Then, you can use an internalforLoop to display these article titles and links. This usually involves more complex template structures, but AnQiCMS provides enough flexibility to achieve this.

**Q2: If I change the URL alias of a category

Related articles

Does AnQiCMS support adding external links in the navigation menu and how to set it up?

## SecureCMS Navigation Menu: Easily integrate external links to expand your website ecosystem In today's fast-paced digital world, an efficient and user-friendly website navigation system is undoubtedly a guiding light for users visiting the website.It not only guides visitors to deeply explore your content, but is also the key to connecting the brand ecosystem and enhancing the user experience.As an experienced website operations expert, I fully understand the importance of the flexibility of the navigation menu for content strategy, especially whether it can add external links.

2025-11-07

How is the display order of AnQiCMS navigation menu items managed and adjusted in the backend?

As an experienced website operation expert, I am well-versed in all the functions of AnQiCMS, especially its design concepts in content management and user experience optimization.Today, let's delve into a seemingly simple but crucial feature for website structure and user experience: how the display order of AnQiCMS navigation menu items is managed and adjusted in the background.A clear and logical navigation menu is the foundation of a successful website.It not only helps users find the information they need quickly, but it is also an important basis for search engines to understand the structure of websites.

2025-11-07

How to get the link address and display name of the navigation item in the AnQiCMS template?

As an experienced website operations expert, I am well aware of the importance of an efficient and flexible CMS system for content operations.AnQiCMS with its powerful performance in Go language and the ease of use of the Django template engine indeed provides us with great convenience.Today, let's delve deeply into an important topic in website template development: how to accurately obtain the link address and display name of navigation items in AnQiCMS templates?

2025-11-07

How to specify different navigation categories with the `typeId` parameter of AnQiCMS navigation tags?

As an experienced website operations expert, I know that a flexible and efficient navigation system is crucial for website user experience and Search Engine Optimization (SEO).AnQiCMS does an excellent job in this aspect, it provides great convenience for the customization of website navigation through its powerful template tag system, especially with the `navList` tag配合`typeId` parameter.Today, let's delve deep into the mysteries of this `typeId` parameter and how to cleverly use it to manage different types of navigation categories.

2025-11-07

What are the cases where the `PageId` field of AnQiCMS navigation items takes effect?

## AnQiCMS navigation item's `PageId` field: When does it unleash the magic of precise navigation?In AnQiCMS (AnQiCMS) such a rich-featured and highly customizable content management system, each configuration item carries a specific mission.Navigation serves as the skeleton of a website, its importance is self-evident.When delving into the navigation settings of AnQiCMS, you will find a field named `PageId`.

2025-11-07

If AnQiCMS navigation tag does not specify `typeId`, which navigation list will be called by default?

The mystery of AnQiCMS navigation tags: Default navigation behavior when 'typeId' is not specified In website operation, the navigation system is undoubtedly the cornerstone of user experience and information architecture.A well-designed, logical navigation can quickly guide users to the information they need, enhancing the overall usability of the website.AnQiCMS (AnQiCMS) is a powerful and flexible content management system that provides intuitive template tags, allowing developers and operators to easily build complex navigation structures. Among them

2025-11-07

How to combine the AnQiCMS navigation list tag with the `siteId` parameter to achieve navigation calls between multiple sites?

## Mastering Multi-Site Navigation: Deep Analysis of AnQiCMS `navList` Tag and `siteId` Parameter In today's complex and ever-changing network environment, many businesses and content operators are no longer satisfied with a single-site operation model.Brand extension, regional station, independent product line display, all催生了the need for multi-site management.AnQiCMS (AnQiCMS) is a system specifically designed for enterprise-level content management, deeply understanding this field, and its powerful multi-site management function is exactly to solve this pain point.

2025-11-07

How to dynamically display the latest article list under a specific category in the AnQiCMS navigation dropdown menu?

## Masterfully crafted: Dynamically display the latest article list under a specific category in the AnQiCMS dropdown menu As an experienced website operations expert, I fully understand the importance of an efficient and user-friendly navigation system for a website.It is not only a guide for users to explore the content of the website, but also a key to improve user experience and optimize the efficiency of search engine crawling.

2025-11-07