In AnQiCMS, `categoryList` and `pageList` coexist without any issues, a practical template for intelligent operation

Calendar 👁️ 56

As an experienced website operation expert, I know that the flexible use of template tags is the key to building an efficient and multifunctional website. Many AnQiCMS users, especially those who are new to template development, may have a question: "categoryListwithpageListWill using these tags with different functions on the same page cause a conflict?

Today, let's delve deeply into this issue and reveal the design philosophy and **practice of AnQiCMS in handling such scenarios, helping everyone better master the template and achieve diverse content display.


Understand the modular design of AnQiCMS: Why do conflicts not exist?

Firstly, I want to make it clear to everyone, in the architecture design of AnQiCMS,categoryListwithpageListThese tags coexist on the same page without any conflict. This is due to the solid and flexible design philosophy of AnQiCMS at the bottom level.

AnQiCMS as an enterprise-level content management system developed based on the Go language, one of its core advantages is itsmodular and high-performance architecture. Each template tag, for examplecategoryListAnd used to get the classification list of content models such as articles or productspageList(Used to retrieve independent single-page lists, such as “About Us”, “Contact Us”, etc.), all representing independent queries and processing of different back-end data sources.

  • Data isolation: categoryListThe query is for the classification data associated with content models (such as articles, products), which have hierarchical structures and specific properties. AndpageListFocusing on independent, non-modeled single-page content. Their data storage logic and acquisition methods are completely separated on the backend, without interference.
  • Independent execution:When AnQiCMS's template engine (similar to Django template engine) renders a page, it parses each tag in order.Each tag will independently execute its data query task and fill the results into the specified template variables.This process is concurrent and independent; the data acquisition of one label will not affect another label.
  • Variable binding:The label is bound to the template context through the specified variable name (such as{% categoryList categories ... %}or{% pageList pages ... %}) to bind the query results. As long as these variable names are unique withintheir respective scopes, the data will not be confused.

In short, you cancategoryListandpageListImagine two chefs each responsible for their own tasks, one preparing the 'dishes category list' on the menu, and the other preparing the 'special page introduction'.They take different ingredients from different refrigerators (database tables), process them at their own workstations (backend logic), and finally put the finished dishes into different plates (template variables), presenting them on the same table (page), the whole process is orderly and without any conflicts.


Be vigilant of "false conflicts": common misconceptions and ways to avoid them

Although the label itself does not conflict, in actual development, users sometimes encounter some seemingly "conflictingUnderstand these misconceptions and avoid them to make your template development smoother.

  1. Variable naming confusion: This is the most common trap. If two tags use the same variable name without distinction, for example, you first use{% categoryList list %}obtained the category list, then again use{% pageList list %}Retrieve a single-page list, then the content of the latter will directly overwrite the variable of the former. When you try to iterate through the code on the subsequent pagelistat that time, you may have only obtained single-page data, and mistakenly think thatcategoryList“Disappeared” or “conflicted”.

    • The way to avoid:Always use different labels for different results:Unique and meaningful variable namesFor example,{% categoryList categories ... %}and{% pageList staticPages ... %}, like thiscategoriesandstaticPagesare two completely independent variables, mutually unaffected.
  2. HTML structure and CSS style overlap:When you display multiple lists on the same page, if their HTML structure is too general (such as all using the fact that they used the same HTML structure for all of them)<ul class="list">),and the CSS styles also use general selectors, then the styles of one list may contaminate another list, causing visual confusion and thus being mistakenly considered as a data conflict.

    • The way to avoid:Provide a unique and clear ID or class name for each list parent containerUnique and clear ID or class nameAnd accurately locate the style through CSS selectors. For example,<div id="category-navigation">and<div id="footer-pages">Then write#category-navigation ul li { ... }and#footer-pages ul li { ... }Such CSS rules.
  3. Template logic confusion:Sometimes, developers may accidentally place the condition judgment or data field intended for another list in the wrong position when handling the loop logic of a list, resulting in rendering results that are not as expected.

    • The way to avoid:When writing template logic, maintain a clear mind,be clear about which variable you are processingdata. Use AnQiCMS template syntax, such as{% if categories %}to ensure that only whencategoriesWhen the variable exists and is not empty, the relevant logic is executed.

3. Practice makes perfect: Build a harmonious coexisting page layout.

To fully utilize the powerful functions of AnQiCMS and harmoniously display various information on the same page, it is crucial to follow the following practice principles:

  1. Use variable naming well:This is the most basic and most important principle.categoryListandpageListAssign completely different variable names, for example:

    {# 侧边栏的分类导航 #}
    <div id="sidebar-category-nav">
        {% categoryList siteCategories with moduleId="1" parentId="0" %}
            <ul>
                {% for cat in siteCategories %}
                    <li><a href="{{ cat.Link }}">{{ cat.Title }}</a></li>
                {% endfor %}
            </ul>
        {% endcategoryList %}
    </div>
    
    {# 底部公司信息单页链接 #}
    <div id="footer-static-pages">
        {% pageList companyPages %}
            <ul>
                {% for page in companyPages %}
                    <li><a href="{{ page.Link }}">{{ page.Title }}</a></li>
                {% endfor %}
            </ul>
        {% endpageList %}
    </div>
    

    BysiteCategoriesandcompanyPagesWith such clear naming, you can immediately know which variable corresponds to which part of the data.

  2. Clarify the HTML structure and scope:Place content rendered from different data sources in independent HTML containers and assign unique IDs or classes.This not only helps to isolate styles, but also makes the code structure clear and easy to maintain.

    {# 顶部主导航可能包含分类列表 #}
    <nav id="main-nav">
        {% categoryList mainNavCategories with moduleId="1" parentId="0" limit="5" %}
            <ul>
                {% for cat in mainNavCategories %}
                    <li><a href="{{ cat.Link }}">{{ cat.Title }}</a></li>
                {% endfor %}
            </ul>
        {% endcategoryList %}
    </nav>
    

    <section id="latest-news">
        <h2>最新文章</h2>
        {# 文章列表 #}
        {% archiveList latestArticles with type="list" moduleId="1" limit="10" %}
            <ul>
                {% for article in latestArticles %}
                    <li><a href="{{ article.Link }}">{{ article.Title }}</a></li>
                {% endfor %}
            </ul>
        {% endarchiveList %}
    </section>
    
    <aside id="about-us-section">
        <h3>关于我们</h3>
        {# 特定单页内容 #}
        {% pageDetail aboutPageContent with token="about-us" %}
            <p>{{ aboutPageContent.Description|truncatechars:100 }}</p>
            <a href="{{ aboutPageContent.Link }}">了解更多</a>
        {% endpageDetail %}
    </aside>
    

Related articles

How to ensure that the `categoryList` generates absolute path links for external reference or SEO?

As an expert who deeply understands website operation, I know the importance of the standardization of website links for search engine optimization (SEO) and user experience.In such an efficient and powerful content management system as AnqiCMS, ensure that category links are presented in absolute path form, which not only enhances the visibility of the website in search engines but also facilitates the citation and sharing of content on external platforms.Today, let's delve into how to elegantly achieve this goal in AnqiCMS.### The Foundation for Optimizing SEO and External References: Understanding the Value of Absolute Paths Imagine that

2025-11-06

`categoryList`is there a difference or**practice**in the way it is called in the mobile template and PC template?

As an experienced website operations expert, I am well-versed in the powerful functions and essence of content operation of AnQi CMS, and I am delighted to delve into the calling method of the `categoryList` tag in the mobile and PC templates of AnQi CMS, as well as how to use its features to achieve efficient and user-friendly content presentation.On a day when content marketing and user experience are increasingly important, the performance of a website on different devices is crucial.AnQi CMS understands this, as can be seen from its project advantages and core features, it provides "adaptive, code adaptation"}

2025-11-06

How to customize the `categoryList` in multi-level nesting, the character style and content before the child category `Spacer`?

As an experienced website operations expert, I am well aware of the importance of website navigation and content classification for user experience and SEO.AnQiCMS (AnQiCMS) with its flexible template engine and rich tag system provides us with powerful content display capabilities.Today, let's delve deeply into a detail that is common in multi-level category displays but often overlooked - how to customize the `Spacer` character style and content before the subcategory in the `categoryList` tag.### Perceiving the Beauty of Hierarchical Layers

2025-11-06

Does the `categoryList` tag output the `item.Content` field support automatic conversion of Markdown formatted content?

As an expert in website operations for many years, I deeply understand the intricacies of content presentation, especially in content management systems, how to flexibly and efficiently handle different formats of content is the key to improving website user experience and operational efficiency.Today, let's discuss a common question about AnQiCMS (AnQiCMS) content display: 'Does the `categoryList` tag output the `item.Content` field support automatic conversion of Markdown format content?'}]

2025-11-06

Does the `categoryList` tag support fuzzy search or filtering by category name (without going through URL parameters)?

As an experienced website operation expert, with a deep understanding of the various functions and content operation strategies of AnQiCMS, I am more than happy to analyze whether the `categoryList` tag in AnQiCMS supports fuzzy search or filtering based on category names, an important issue.In the Anqi CMS template system, the `categoryList` tag is the core tool for developers and content operators to obtain and display the website category list.It helps us build clear website navigation and content structure with its concise and efficient characteristics. However,

2025-11-06

How to extend the additional features of the `categoryList` tag without modifying the AnQiCMS core code?

As an experienced website operations expert, I fully understand how to skillfully utilize the existing functions of the CMS system to expand without touching the core code, which is crucial for maintaining system stability and reducing upgrade costs.AnQiCMS (AnQiCMS) offers us a powerful tool for deep customization at the content operation level with its flexible template engine and rich tag system, among which the `categoryList` tag is often a point where we need to expand the function.In Anqi CMS

2025-11-06

Is the HTML structure generated by `categoryList` friendly to search engine crawlers, and how can it be optimized?

As an experienced website operations expert, I know that every detail can affect the performance of a website in search engines.Today, let's delve deeply into the `categoryList` tag generated by AnQiCMS, the degree of friendliness of its HTML structure to search engine spiders, and how we can cleverly optimize it to improve the website's SEO performance.Since its inception, AnQi CMS has been favored by operators for its SEO-friendly design concept.

2025-11-06

How to handle the pagination problem when nesting `archiveList` inside `categoryList`?

As an experienced website operations expert, I have accumulated rich experience in the content management practice of AnQiCMS.I am well aware that when facing the powerful template tag system of AnQiCMS, how to skillfully combine them to achieve the expected content display effect is a challenge that many operators and developers will encounter.Today, let's delve into a common yet confusing issue: how to properly handle the pagination problem of `archiveList` when nesting `categoryList`?

2025-11-06