As an expert who has been deeply involved in website operation 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.AnQiCMS, with its excellent flexibility and powerful features, provides many conveniences in this regard.Today, let's delve into a common template calling issue: 'Can the AnQiCMS navigation label be called in non-navigation template pages (such as article detail pages) for other navigation categories?'
The answer is affirmative, not only can it, but this is also a flexible application 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 on the syntax of the Django template engine, the core of which is to separate content from presentation and to achieve dynamic content calls through a powerful tag system.In AnQiCMS, whether it is an article list, product details, or homepage layout, they are all built 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 be used anywhere it is needed.
navListNavigation list label, as the name implies, it is mainly used to obtain the navigation link list of a website. But its design is far from this. It provides a namedtypeIdThe key parameters, which is the core of what we are discussing today.
navListThe core of the navigation label andtypeId
In the Anqi CMS backend "Website Navigation Settings", you can create and manage different navigation categories.For example, in addition to the default 'top navigation', you can also create 'footer navigation', 'sidebar navigation', and even 'article recommendation navigation' according to your business needs.Each navigation category created by the system will be assigned a uniquetypeId. ThistypeIdThis is the "ID card" we use to distinguish and call different navigation lists.
navListThe complete usage method of the label is usually like this:{% navList navs with typeId="X" siteId="Y" %}.
navsIt is the variable name you specify for the current navigation list, which can befortraversed in a loop to get each navigation item.typeIdParameter: This is the core. By specifying differenttypeId(For example,)typeId="2"representing the footer navigation,typeId="3"representing the sidebar navigation),navListtag, you can accurately extract the one you specified from the database.typeIdThe set of configured navigation links.siteIdParameter: If you have enabled the AnQi CMS multi-site management feature and want to call data from other sites, you can specify this parameter.For single-site users, usually no entry is required.
Flexible operation to call navigation content in non-navigation templates
Imagine a scenario, you are designing an article detail page (the corresponding template file might bearchive/detail.htmlOr a similar name). On this page, you not only display the article content itself, but 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 tags across templates is particularly important:
Prepare for background configuration:First, create or edit your non-primary navigation category in 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.After setting up, the system will allocate one for the "recommended products"
typeId(Assuming that is)typeId="5"Similarly, if you want to call the "Friend Links" navigation in the footer, make sure it also has a correspondingtypeId(Assuming that is)typeId="6")Call in the article detail page template:Now, open your article detail page template (for example
archive/detail.html)。At the sidebar position where you want to display the "Recommended Products" section, 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>
By the above example, you can see that in the article detail page of this "non-navigation template", we successfully utilizenavListtags and theirtypeIdParameters, calls and displays two completely different navigation categories: 'Recommended Products' and 'Friendly Links'.
Why is this flexibility crucial?
The ability to call navigation tags across templates brings a variety of benefits to website operation:
- Improve user experience:Provide relevant navigation on the content page, which can 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 reasonable internal link structure is crucial for search engine optimization.By dynamically calling navigation, you can easily generate rich and organized internal links on different pages, helping search engines better understand the structure and content relevance of the website.
- Simplify content management:Navigation links can be added, modified, and deleted uniformly 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 be frequently updated.
- Improve template reusability:There is no need to design and hard-code navigation modules separately for each page, a generic template framework can adapt to various content display needs through parameterized calls.
In short, the Anqi CMS'snavListTags are not limited to building the main menu of a website. With its flexibility,typeIdA parameter that is a powerful tool that can be dynamically called and displayed at any location in any template on the website.Make full use of this feature, it will help you build a more intelligent, efficient, and user-friendly website.
Frequently Asked 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 different innavListtags.typeIdParameters 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 point correctly when called on the article detail page?A2: Yes, no problem at all. The Anqi CMS navigation management backend supports selecting multiple 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 maintain their original, 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 what you need to use when calling it in the template.typeIdValue. It is usually found in the URL or page element after clicking edit if it is not directly displayed.