How to accurately call the navigation links under the new navigation category after creating it in the template?

Calendar 👁️ 56

AnQiCMS is an efficient content management system, one of its core advantages lies in its powerful content organization and template customization capabilities.As a website person proficient in AnQiCMS operation, I know the importance of a flexible navigation system for user experience and website structure optimization.When you create a new navigation category in the background and want to present it accurately on the website front-end template, AnQiCMS provides intuitive and powerful template tags to meet this need.

Understanding the navigation management mechanism of Anqi CMS.

In the AnQiCMS management backend, the navigation system is highly configurable.You can access the 'Navigation Settings' under 'Background Settings' to manage the website's navigation structure.Here not only has the system default main navigation, but it also allows you to create custom navigation areas through 'Navigation Category Management'.For example, in addition to the conventional top navigation, you may also need a navigation specifically designed for the footer, sidebar display, or a specific marketing campaign.

Creating a new navigation category is a very simple process: Click on "Navigation Category Management" page, then click "Add New Navigation Category", and name your new navigation category (for example, "Footer Navigation") and save. After saving, the system will assign a unique identifier to this new category, namelytypeIdAfter that, you can add specific navigation links to this new category just like you would manage other navigation.These links can be to the "category page link" of the in-site article classification, the "built-in link" to specific content, or the "external link" to external websites, fully satisfying your content display needs.

Core: The key tag for invoking custom navigationnavList

In the template system of AnQiCMS,navListThe tag is a core tool for retrieving and rendering the navigation list. This tag is designed to be very flexible, allowing you to accurately retrieve any defined navigation category according to your needs.navListThe power of labels lies in itstypeIdThis is the bridge that associates the specific navigation category created in the background with the frontend template. After creating a new navigation category in the background, the system will assign one to ittypeId. In the template, you just need to specify thistypeId,navListtag to accurately retrieve all navigation links under the category.

navListThe usage method of the tag is usually{% navList 变量名称 with typeId="您的导航类别ID" %}, and ends with:{% endnavList %}end. You can use within the tag.forLoop to traverse the obtained navigation items. Each navigation item (usually named in the loop)item) contains a series of useful properties, such asTitle(Navigation title),Link(navigation link),IsCurrent(Whether the current page link is), and for handling multi-level navigation,NavListetc.

The steps to accurately call the new navigation category in the template

To display the new navigation category you created in the AnQiCMS backend on the website front end, you need to follow the following steps:

First, in your AnQiCMS backend, go to "Backend Settings" -> "Navigation Settings". In the "Navigation Category Management" section, find the new navigation category you just created (such as "Footer Navigation") and note down the correspondingtypeIdThis ID is automatically generated by the system and is the unique identifier for calling the navigation. Assume thistypeIdIs2The default navigation is usually1The newly created will be other numbers). Next, make sure you have added at least one navigation link to the new navigation category.

Then, open the template file you want to display this navigation. AnQiCMS template files are usually located in/templateIn the directory of your theme folder. For example, if you want to display this navigation in the footer of the website, you may need to editpartial/footer.htmlorindex.htmletc. Insert at the position where you want to display the navigationnavListLabel, and throughtypeIdParameters specify the navigation category ID you recorded.

A typical call example would be like this:

<nav class="footer-nav">
    <ul>
        {% navList footerNavs with typeId="2" %} {# 假设您的“页脚导航”的 typeId 是 2 #}
        {%- for item in footerNavs %}
        <li class="footer-nav-item {% if item.IsCurrent %}active{% endif %}">
            <a href="{{ item.Link }}" title="{{ item.Title }}">{{item.Title}}</a>
            {%- if item.NavList %} {# 如果存在子导航 #}
            <ul class="sub-footer-nav">
                {%- for subItem in item.NavList %}
                <li class="sub-footer-nav-item {% if subItem.IsCurrent %}active{% endif %}">
                    <a href="{{ subItem.Link }}" title="{{ subItem.Title }}">{{subItem.Title}}</a>
                </li>
                {% endfor %}
            </ul>
            {% endif %}
        </li>
        {% endfor %}
        {% endnavList %}
    </ul>
</nav>

In this example,footerNavsIs the variable name you define for the navigation list,typeId="2"This ensures that the link being accessed is under the "Footer Navigation" category you created. ThroughforLoop throughfooterNavseach one in theitemYou can accessitem.Titleanditem.LinkTo generate navigation links. At the same time, throughitem.IsCurrentproperty, you can add a special CSS class to the navigation item corresponding to the current visited page (for exampleactiveThus, enhancing the user's perception of the current location. If your navigation category supports secondary navigation,item.NavListthe properties will also include a sub-navigation list, you can nestforto render them in a loop.

After completing the template modification, save the file. If your AnQiCMS has enabled template caching, you may need to clear the cache in the "Update Cache" feature on the backend to ensure that the changes take effect immediately.Refresh your website page, and you will find that the new navigation categories have been presented on the front end according to your design.

**Practice and Precautions

In practice, to better manage and maintain the website, it is recommended to use clear and explicit names for different navigation categories and to correspond accurately in the templatetypeId. At the same time, to make use ofitem.SubTitleoritem.DescriptionProperties such as, you can add more auxiliary information to navigation links to enrich the user experience. In a multi-site environment,navListTags also supportsiteIdParameter, allows you to retrieve navigation data under a specific site, which is particularly important for managing enterprises with multiple sub-sites or multi-language sites.

In this way, AnQiCMS greatly simplifies the process of creating and invoking custom navigation, allowing website operators to focus more on content presentation and user experience optimization, rather than on cumbersome code writing.


Frequently Asked Questions (FAQ)

How to determine the navigation category I have just createdtypeId?The AnQiCMS backend will not usually display directly when you create a new navigation categorytypeId. You can first create a new navigation category and add some links to it. Then, you can check the tables in the database related to navigation such asnav_typeOr a similar table structure, the specific table name may vary depending on the version), or in some cases, by viewing the source code of the backend page, you can find the ID corresponding to the new navigation category.The most direct method is to click on 'Edit your new navigation category' on the 'Navigation Settings' page, usually the URL will contain the ID of the navigation category.

My navigation link is not displayed in the template, how should I investigate?First, please checktypeIdIs it correct. Make sure you are innavListin the tag usedtypeIdIt is completely consistent with the actual navigation category ID created on the back-end.Secondly, confirm that the navigation category you are calling has indeed added navigation links.If the link is empty, the front end will naturally not display any content.In addition, check if the template file path is correct, as well as whether there are syntax errors causing the template to fail to parse.Finally, don't forget to clear the AnQiCMS system cache to ensure that the latest templates and data are loaded.

navListDoes the tag support creating navigation menus with more than two levels?According to AnQiCMS design,navListThe label currently supports up to two levels of navigation links. This means you can have a main navigation, as well as a sub-navigation under the main navigation.If you need a deeper level of navigation structure, you may consider custom template logic, or design the sub-navigation as an independent navigation category, and combine it with JavaScript to implement more complex interaction effects on the front end.

Related articles

How to set up the Anq CMS navigation to improve the depth of access to website content?

As an experienced security CMS website operation personnel, I know that the navigation system is crucial for improving the depth of website content access.A well-designed navigation not only guides users to find the information they need quickly but also stimulates their desire to explore, allowing them to stay longer on the website and visit more pages.AnQi CMS provides flexible and powerful navigation settings that can help us effectively achieve this goal.### Navigation, the guide of a website's structure and depth of content Website navigation is the first door of interaction between users and content

2025-11-06

In Anq CMS, besides the top navigation, what types of custom navigation can be created?

As an experienced Anqi CMS website operator, I am well aware that a flexible navigation system is crucial for the user experience and content management of the website.The Anqi CMS provides powerful custom capabilities in navigation functions, surpassing traditional top navigation, aiming to help operators build a website structure that better meets business needs and user habits.The navigation design concept of AnQi CMS is not limited to a single main navigation area, it allows operators to create diversified custom navigation according to different functional areas and content types of the website.

2025-11-06

What are the similarities and differences between the 'Friend Links' feature and the 'Navigation Settings' in AnQi CMS?

As a senior CMS website operation personnel, I know that each function in the content management system carries specific operation strategies and user experience objectives.In AnQi CMS, although the "Friend Links" and "Navigation Settings" both involve the management and display of website links, there are significant differences in design concepts, functional focus, application scenarios, and impact on website operations.Understanding these similarities and differences is crucial for us to efficiently utilize Anqi CMS to build and optimize websites.### Friend Links: The Bridge Between External Connections and SEO Strategies Friend Links

2025-11-06

How to prevent external links in AnQi CMS navigation from being tracked by search engines?

As an experienced Anqi CMS website operations personnel, I am well aware of the key role of website navigation in user experience and search engine optimization.Manage external links in the navigation well, ensuring that they are processed according to our wishes by search engines is an indispensable aspect of website operation. I will elaborate in detail on how to prevent external links in navigation links from being tracked by search engines in Anqi CMS.

2025-11-06

Will the 'Link' field in the Anqi CMS navigation automatically handle pseudo-static URLs?

As an experienced CMS website operation personnel of an enterprise, I know the importance of URL structure for website SEO, as well as the common questions about link handling in the content creation process.About the `Link` field of AnQi CMS navigation links, I can clearly tell you that the system has given it comprehensive consideration and automatic processing. AnQi CMS is a highly SEO-focused enterprise-level content management system, one of its core advantages is the management of 'pseudo-static and 301 redirection'.This feature is designed to optimize the website's URL structure

2025-11-06

How to implement a single-page 'Contact Us' link in the Anqi CMS navigation?

As an experienced website operator familiar with AnQiCMS, I know that a user-friendly and content-rich 'Contact Us' page is crucial for improving user experience and promoting business development.Integrating such pages into navigation efficiently not only allows users to quickly find the information they need, but also demonstrates the professionalism of the website and its attention to user needs.Below, I will elaborate on how to achieve this goal in AnQiCMS.

2025-11-06

How the example code in the `tag-navList.md` document helps developers understand the implementation of multi-level navigation?

As an expert deeply involved in the operation of Anqi CMS websites, I know that a highly efficient and flexible navigation system is crucial for the user experience of the website and Search Engine Optimization (SEO).Strong support is provided by AnQiCMS in navigation management, especially its `navList` template tag, which provides a clear and powerful tool for developers to understand and implement multi-level navigation.

2025-11-06

What is the specific restriction mentioned in `help-setting-nav.md` regarding the maximum of 2-level navigation links?

As a professional who deeply understands the operation of Anqi CMS, I am well aware of the importance of a clear navigation structure for user experience and the overall efficiency of the website.About the limit of "up to 2-level navigation links" mentioned in the `help-setting-nav.md` document, this is indeed a core consideration in the design of the navigation function in Anqi CMS, aiming to balance the practicality and simplicity of the system.### The "Most 2 Levels" Limitation Parsing of AnQi CMS Navigation In the navigation settings of AnQi CMS

2025-11-06