As an expert who has been deeply involved in website operations for many years, I fully understand that how to flexibly call and display information in a content management system is the key to improving website user experience and operational efficiency.Auto CMS (AutoCMS) provides many conveniences in this aspect with its excellent flexibility and powerful features.Today, let's delve into a common template calling issue: 'Can AnQiCMS navigation tags call other navigation categories in non-navigation templates (such as article detail pages)?'}]
The answer is affirmative, not only can it, but it is also a flexible application method encouraged by the powerful template mechanism of AnQi CMS.
Deeply understand the template and tag mechanism of AnQi CMS
The template design of Anqi CMS draws inspiration from the Django template engine syntax, the core of which is to separate content from presentation and to dynamically call content through a powerful tag system.In AnQiCMS, whether it is the article list, product details, or homepage layout, they are all constructed through template files and built-in tags.This means that the function of a label is usually not limited to a specific template type, but can play a role anywhere it is needed.
navListNavigation list label, as the name implies, it is mainly used to obtain the navigation link list of the website. But its design is far more than that. It provides a namedtypeIdThe critical parameters, which is the core of what we are discussing today.
navListThe core of the navigation tab.typeId
In the "Website Navigation Settings" section of the AnQi CMS backend, you can create and manage different navigation categories.For example, in addition to the default "top navigationtypeId. ThistypeIdIt is the "ID card" we use to distinguish and call different navigation lists.
navListThe complete usage of the label is usually like this:{% navList navs with typeId="X" siteId="Y" %}.
navsIt is a variable name you specify for the current navigation list, which can be used subsequently inforthe loop to iterate through each navigation item.typeId参数:This is the core. By specifying differenttypeId(For example,typeId="2"represent the footer navigationtypeId="3"represent the sidebar navigation)navListlabels, you can accurately extract the data you have marked in the database.typeIdConfigured navigation link collection.siteId参数:If you have enabled the multi-site management feature of Safe CMS and want to call data from other sites, you can specify this parameter.For single-site users, it is usually not necessary to fill in.
The actual operation of flexibly calling navigation content in non-navigation template types
Imagine a scenario, you are designing an article detail page (the corresponding template file might be)archive/detail.htmlor similar name).On this page, in addition to displaying the article content itself, you also hope to display a 'Recommended Products' navigation list in the sidebar or reuse the 'Friend Links' navigation in the footer.
In this case,navListThe ability to call labels across templates is particularly important:
Background configuration preparation:Firstly, create or edit your non-primary navigation category in the "Website Navigation Settings" of the Anqi CMS backend.For example, you can create a navigation category named 'Recommended Products' and add the product links you want to display in the sidebar of the article detail page.
typeId(Assuming it is)typeId="5")。Similarly, if you want to call the "Friend Links" navigation in the footer, make sure it also has a correspondingtypeId(Assuming it is)typeId="6").Call it in the article detail page template:Now, open your article detail page template (for example
archive/detail.html) At the sidebar location where you want to display 'Recommended Products', you can write the code like this:<div class="sidebar-products"> <h3>相关产品推荐</h3> <ul> {% navList relatedProductsNav with typeId="5" %} {# 假设“相关产品推荐”的typeId是5 #} {% for item in relatedProductsNav %} <li><a href="{{ item.Link }}" {% if item.Nofollow %}rel="nofollow"{% endif %}>{{ item.Title }}</a></li> {% endfor %} {% endnavList %} </ul> </div> {# 假设在页面底部也需要调用另一个导航类别,例如友情链接 typeId=6 #} <footer class="site-footer"> <div class="footer-links"> <h3>友情链接</h3> <ul> {% navList friendLinksNav with typeId="6" %} {# 假设“友情链接”的typeId是6 #} {% for item in friendLinksNav %} <li><a href="{{ item.Link }}" {% if item.Nofollow %}rel="nofollow"{% endif %} target="_blank">{{ item.Title }}</a></li> {% endfor %} {% endnavList %} </ul> </div> {# 其他页脚内容 #} </footer>
Through the above example, you can see that in this 'non-navigation template' of the article detail page, we have successfully usednavListTags and theirtypeIdParameters, calls and displays two completely different navigation categories: "Recommended Products" and "Friend Links".
Why is this flexibility crucial?
This ability to call navigation tags across templates brings many benefits to website operations:
- Enhance user experience:Provide relevant navigation on the content page to guide users to discover more interesting content or products, reduce the bounce rate, and extend the user's stay time.
- Optimize on-site SEO:A well-structured internal link is crucial for search engine optimization.Through dynamic navigation calls, you can easily generate rich and organized internal links across different pages, helping search engines better understand the structure and content relevance of the website.
- Simplify content management:The addition, modification, and deletion of navigation links can all be done in the background, without manually modifying each template file.This greatly reduces the complexity and error rate of website maintenance, especially for websites that need to update content frequently.
- Increase template reusability:No need to design and hard-code navigation modules for each page individually. By parameterized calls, a universal template framework can adapt to various content display needs.
In short, the Anqi CMS isnavListThe label is not limited to the main menu of building a website. With its flexibility,typeId参数,it is a powerful tool that can be dynamically called and displayed at any location and in any template on the website, allowing for arbitrary navigation categories.Fully utilizing this feature will help you build a more intelligent, efficient, and user-friendly website.
Common Questions (FAQ)
Q1: Can I call multiple different navigation categories in the same article detail page template?A1: Yes, absolutely. As shown in the example in the article, you can specify differentnavListin the tags.typeIdParameters can be used to call different navigation categories multiple times. For example, one for related recommendations in the sidebar and another for auxiliary navigation in the footer.
Q2: If my navigation category includes article categories or single page links, will these links correctly point to the article detail page when called?A2: Yes, no problem at all.The navigation management backend of AnQi CMS supports selecting various link types, including built-in links (such as home page, model home page), category page links, and external links.No matter which template is called, these links will always maintain their original and correct direction.
Q3: How do I know the navigation category I createdtypeIdWhat is it?A3: You can view it on the "Website Navigation Settings" page in the Anqi CMS backend. Each navigation category usually has a unique identifier or ID, which is the one you need to use when calling it in the templatetypeIdValue. If not directly displayed, it is usually found in the URL or page elements after clicking Edit.