How to set up AnQi CMS article or product list according to specified conditions

Calendar 👁️ 65

When using AnQi CMS to manage website content, efficiently displaying articles or product lists is the key to enhancing user experience and website functionality.AnQi CMS provides flexible and powerful template tags, allowing us to precisely control the output of content based on various specified conditions.Whether it is to display the latest articles by category or to filter products by specific attributes, Anqi CMS can help us easily achieve it.

Flexible control of content: document list tagsarchiveList

The core content display capability of Anqi CMS mainly involvesarchiveListThe tag allows us to retrieve articles, products, or other types of content from the database and to filter and sort according to the conditions we set.

To usearchiveListLabel, the basic structure is like this:

{% archiveList archives with [参数列表] %}
    {% for item in archives %}
        <!-- 在这里显示每个文章或产品的详细信息 -->
        <a href="{{ item.Link }}">{{ item.Title }}</a>
        <!-- ...更多内容,如简介、图片等 -->
    {% empty %}
        <p>暂时没有符合条件的内容。</p>
    {% endfor %}
{% endarchiveList %}

HerearchivesIt is the variable name we define for the list of content obtained, you can name it according to your preference.itemrepresents each individual item in the list.

Let's delve deeper into the commonly used parameters, which are the keys to controlling the display of the list:

  • Specify content model (moduleId)This is the most basic condition. Anqi CMS supports various content models such as articles and products. If you want to display a list of articles, you usually specifymoduleId="1"(Article model ID); it may be for a product listmoduleId="2"The specific ID can be viewed in the background under "Content Management" -> "Content Model". For example:moduleId="1".

  • Filter by category (categoryId):We often need to display the content of a specific category. You can specify one or more category IDs using a comma, for examplecategoryIdParameter specifies one or more category IDs (separated by commas), for examplecategoryId="1,5,8"If you want to display the content of the current page category without manually specifying the ID, Anqi CMS will intelligently read the current category ID.If you want to get all the content or do not want it to automatically read the current category ID, you can explicitly set it tocategoryId="0"。“Furthermore,”excludeCategoryIdParameters allow you to exclude certain categories of content.

  • Control the number of displays and pagination (limitandtype):

    • limitParameters are used to control the number of contents displayed at one time, for examplelimit="10"It will display the latest 10 items. It also supports offset mode, such aslimit="2,10"It means to start from the 2nd item and get 10 data items.
    • typeThe parameter is very important, it determines the display style of the list. Set totype="list"will only displaylimita specified number of contents; set totype="page"will enable pagination in the content list, which needs to be coordinated withpaginationTags are used together; andtype="related"It is used to display recommended content related to the current article, usually on the article detail page.
  • Content sorting (order)The display order of the content is also important. You can choose different sorting methods as needed, such asorder="id desc"means in descending order by ID (latest release),order="views desc"means in descending order by views (most popular),order="sort desc"The sorting is in descending order according to the custom sorting value set by the backend.

  • Filter by recommended attributes (flag): AnQi CMS allows you to set various recommended attributes for articles or products, such as "top news", "recommended", "slider", and so on. You can useflagParameters to filter content with specific attributes, such asflag="c"Only display content marked as 'Recommended.'excludeFlagThe parameter is used to exclude content with specific attributes.

  • Including content with subcategories (child): By default,archiveListContains content under subcategories (child=true) If you only want to display the content directly managed by the current category without including the content of its subcategories, you can set it tochild=false.

  • Fuzzy search (q):Whentype="page"when,you can go throughqto search for keywords by parameters,for exampleq="SEO优化".If the URL containsq=关键词.archiveListit will automatically read and search.

  • custom field filteringThis is the strength of Anqi CMS. If you customize fields in the content model, such as adding "Color" or "Size" fields to the "Product" model, and set these fields as filterable in the background, then you can filter through the query parameters of the URL (such as?color=红色&size=L) to dynamically filter content.

Dynamic interaction: document parameter filter tagarchiveFilters

When we need to build a page that allows users to select conditions to filter content (such as house types, product colors, price ranges, etc.)archiveFiltersThe tag comes into play. It does not directly display content, but generates a series of clickable filter links, which include dynamically changing filter parameters.

archiveFiltersThe basic usage is as follows:

{% archiveFilters filters with moduleId="[模型ID]" allText="[全部文本]" %}
    {% for item in filters %}
        <div class="filter-group">
            <span>{{ item.Name }}:</span>
            <ul>
                {% for val in item.Items %}
                    <li class="{% if val.IsCurrent %}active{% endif %}">
                        <a href="{{ val.Link }}">{{ val.Label }}</a>
                    </li>
                {% endfor %}
            </ul>
        </div>
    {% endfor %}
{% endarchiveFilters %}
  • moduleId: Specify the content model you want to generate a filtering condition for.
  • allText: Set the display text for the 'All' or 'Unlimited' options, if set tofalseit will not be displayed.

This tag will generate afiltersvariable that contains each filterable fielditem.Name) and all its optional valuesitem.Items). Each optional value has aLabel(Display Text),Link(URL with filter parameters after clicking) andIsCurrent(Determine if currently selected). The page will refresh after the user clicks on these links,archiveListThe tag can display filtered content based on new parameters in the URL.

Page control:paginationTag

WhenarchiveListoftypethe parameter topagewhen,you,need,to,cooperatepaginationuse,a,tag,to,create,pagination,navigation

{% pagination pages with show="5" %}
    <ul class="pagination-list">
        {% if pages.PrevPage %}<li class="prev"><a href="{{ pages.PrevPage.Link }}">上一页</a></li>{% endif %}
        {% for item in pages.Pages %}<li class="{% if item.IsCurrent %}active{% endif %}"><a href="{{ item.Link }}">{{ item.Name }}</a></li>{% endfor %}
        {% if pages.NextPage %}<li class="next"><a href="{{ pages.NextPage.Link }}">下一页</a></li>{% endif %}
    </ul>
{% endpagination %}

showthe,parameter,can,control,the,number,of,page,numbers,displayed,in,pagination,navigation

actual,application:build,a,product,list,page

Assuming we need a product list page that can display all products and allow users to filter by "color" and "material", and support pagination and sorting by the most recently published.

  1. Configure the content model and filter fields in the background:

    • Ensure there is a "Product" content model (moduleIdAssume2)
    • Add custom fields to the product model, such ascolor(Color, single selection type, optional values: Red, Blue, Green) andmaterial(Material, type is a single selection, optional values: metal, plastic, wood), and check the 'Filterable' option.
  2. In the template file (for exampleproduct/list.html) write the code:

    {% extends "base.html" %}
    
    {% block content %}
        <div class="product-filters">
            <h3>筛选产品</h3>
            {% archiveFilters filters with moduleId="2" allText="不限" %}
                {% for item in filters %}
                    <div class="filter-group">
                        <span class="filter-name">{{ item.Name }}:</span>
                        <ul class="filter-options">
                            {% for val in item.Items %}
                                <li class="{% if val.IsCurrent %}active{% endif %}">
                                    <a href="{{ val.Link }}">{{ val.Label }}</a>
                                </li>
                            {% endfor %}
                        </ul>
                    </div>
                {% endfor %}
            {% endarchiveFilters %}
        </div>
    
        <div class="product-list-container">
            <h2>产品列表</h2>
            {% archiveList products with moduleId="2" type="page" order="id desc" limit="12" %}
                {% for item in products %}
                    <div class="product-item">
                        <a href="{{ item.Link }}">
                            <img src="{{ item.Thumb }}" alt="{{ item.Title }}">
                            <h3>{{ item.Title }}</h3>
                            <p>{{ item.Description }}</p>
                        </a>
                    </div>
                {% empty %}
                    <p>没有找到符合条件的产品。</p>
                {% endfor %}
            {% endarchiveList %}
    
            <div class="pagination-area">
                {% pagination pages with show="5" %}
                    <ul class="pagination-list">
                        {% if pages.PrevPage %}<li class="prev"><a href="{{ pages.PrevPage.Link }}">上一页</a></li>{% endif %}
                        {% for item in pages.Pages %}<li class="{% if item.IsCurrent %}active{% endif %}"><a href="{{ item.Link }}">{{ item.Name }}</a></li>{% endfor %}
                        {% if pages.NextPage %}<li class="next"><a href="{{ pages.NextPage.Link }}">下一页</a></li>{% endif %}
                    </ul>
                {% endpagination %}
            </div>
        </div>
    {% endblock %}
    

With such settings, users can not only see the basic list of products but also dynamically view products with different attributes based on the page filtering conditions, greatly enhancing the interactivity and information search efficiency of the website.The Anqi CMS template tag system is flexible and easy to understand, and with a little practice, you can create a feature-rich list page.

Frequently Asked Questions (FAQ)

  1. Ask: How can I display a list of multiple conditions (such as latest articles, popular products, recommended events) on the same page? Answer:You can use multiple on the page.archiveListLabel, each label sets different parameter conditions. For example, onearchiveListUsed to getmoduleId="1"andorder="id desc"article list, anotherarchiveListUsed to getmoduleId="2"andflag="c"product list. As long as eacharchiveListlabel specifies different variable names (such asarticles,products,activitiesThey can be displayed on the same page without interfering with each other.

  2. Question: I have setarchiveListthe condition, but there is no content displayed on the page, what could be the reason? Answer:First, please checkmoduleId

Related articles

How to implement adaptive display of AnQi CMS content on different devices (PC, mobile)?

In today's parallel internet environment with multiple devices, ensuring that website content displays well on different screen sizes is crucial for improving user experience and website professionalism.AnQiCMS (AnQiCMS) fully considers this need, providing a variety of flexible strategies to help users easily achieve adaptive display of content on PC and mobile terminals.One of the core design philosophies of AnQi CMS is to support diverse content display, therefore it is built with three main website modes to meet the challenges of multi-device display: **Adaptive Mode**

2025-11-09

How to optimize URL display and SEO through the pseudo-static feature of AnQi CMS?

In website operation, the structure of the URL (Uniform Resource Locator) not only affects user experience but is also a key element that cannot be ignored in Search Engine Optimization (SEO).A clear, meaningful URL address makes it easier for users to understand the page content, and also helps search engines better crawl and index the website, thereby improving the visibility and ranking of the website.AnQiCMS (AnQiCMS) understands this, and its pseudo-static feature has become a powerful tool for optimizing URL display and SEO. ### One, Static Simulation and SEO: Why Are They So Important?

2025-11-09

How to configure and switch the multilingual content display on the Anqi CMS website?

Today, in an era of increasing globalization, it is an important step to enable your website content to be presented in multiple languages, to expand the market and serve users in different regions.AnQiCMS (AnQiCMS) is an efficient and flexible content management system that fully considers this need and provides a variety of solutions to help you easily configure and switch between multilingual content.Next, we will explore how to effectively manage and display multilingual content in Anqi CMS.### The multilingual concept of AnQi CMS: Distinction between system and content In AnQi CMS, multilingual support is mainly reflected in two levels

2025-11-09

How to use the flexible content model of Anqi CMS to display diverse content structures?

In this era where content is king, the content of websites is no longer limited to simple articles and news.From e-commerce products to event information, from customer cases to job positions, each type of content has its unique structure and display requirements.If a content management system (CMS) can only use a single "article" template to carry all information, it will undoubtedly bring great difficulties to operation, not only making content management efficiency low, but also making the front-end display monotonous, difficult to attract users.

2025-11-09

How to modify and display the overall name and page title of the AnQiCMS website?

In website operation, the overall name of the website and the titles of each page are an important part of the brand image and search engine optimization.They are not only the first impression of visitors to the website, but also a key factor for search engines to understand the content and ranking of the website.AnQiCMS is a content management and SEO design system designed for flexibility and powerful features, helping us easily manage and optimize these core elements. ### Setting and Considerations for the Overall Website Name Firstly, we need to establish the overall name of the website, which typically represents our brand or company name.

2025-11-09

How to customize the AnQiCMS website logo so that it displays correctly on the front page?

AnQi CMS provides a set of intuitive and powerful website management functions, among which customizing the website logo is a crucial link in the construction of the brand image.A clear and professional logo can not only enhance the recognition of the website but also leave visitors with a deep first impression.In AnQiCMS, replacing and managing the website logo is a simple and clear process, and ensures that it is displayed correctly on your website's front-end page.### Core Function and Location: Website Logo Settings Entry Customize the website logo in AnQiCMS

2025-11-09

How to configure the mobile end website address of Anqi CMS to ensure that the content is displayed adaptively on mobile phones?

In today's mobile internet era, the display effect of websites on mobile phones is directly related to user experience and content dissemination efficiency.For users of AnQiCMS, ensuring that content is presented elegantly on various mobile devices is an indispensable aspect of content operation.AnQi CMS provides flexible configuration options and template mechanisms to help you easily achieve this goal.### Overview of AnQi CMS Mobile Adaptation Strategy From the beginning of its design, AnQi CMS has considered the need for multi-terminal access and therefore provides three main website modes to adapt to mobile display

2025-11-09

How to set the copyright information and filing number of the website in AnQiCMS and display them uniformly in the footer?

In website operation, the copyright information and filing number at the bottom (footer) of the website are not only a reflection of the professionalism of the website, but also an important part of legal compliance.For websites built with AnQiCMS, setting and displaying these information uniformly is a simple and direct process.This guide will help you easily complete these configurations in AnQiCMS, making your website look more professional and credible.### Step 1: Set copyright information and record number in AnQiCMS backend AnQiCMS provides a centralized management interface

2025-11-09