How to display a document list based on different conditions (such as categories, recommended properties)?

Calendar 👁️ 64

In Anqi CMS, flexibly displaying website content is the key to improving user experience and meeting operational needs.Whether it is based on the category of the article or the recommendation attributes of the content, the system provides powerful and easy-to-use template tags that allow you to easily customize the display of the document list.

Core tool:archiveListDocument List Tags

The core tool used in AnQi CMS to control the display of document lists isarchiveListThe tag allows you to filter, sort, and limit the number of documents displayed based on various conditions. By configuring this tag appropriately, you can implement complex list display logic.

Display document list by category

Website content is usually organized into different categories, such as "Company News", "Industry Dynamics", or "Product Introduction", etc. If you want to display documents under a specific category on a single page, you can usecategoryIdParameter.

For example, to display the latest article under the 'Company News' category with ID 1, you can set it like this:

{% archiveList latestNews with categoryId="1" moduleId="1" order="id desc" limit="5" %}
    {% for item in latestNews %}
        <li><a href="{{ item.Link }}">{{ item.Title }}</a></li>
    {% endfor %}
{% endarchiveList %}

HeremoduleIdUsed to specify the content model, for example, the 'Article Model' usually corresponds to ID 1. If you do not want the list to automatically obtain the category ID of the current page, you can setcategoryId="0"to explicitly exclude.

In addition, sometimes we only want to display a specific categorydirectlyDocuments included, but not the documents of its subcategories. In this case, you can combinechild="false"parameters to precisely control:

{% archiveList directArticles with categoryId="1" child="false" limit="10" %}
    {# 循环输出文档内容 #}
{% endarchiveList %}

Filter content based on recommended attributes

In addition to categories, Anqi CMS also provides rich recommendation attributes (Flag), allowing you to mark important or special content and flexibly display it on the front end. These properties include headlines[h], recommended[c]of slides[f], special recommendation[a], scroll[s], bold[h], image[p]and jump[j].

For example, if you want to display several articles marked as 'Recommended' on the homepage, you can use it like thisflagparameters:

{% archiveList recommendedArticles with flag="c" moduleId="1" limit="3" %}
    {% for item in recommendedArticles %}
        <h3>{{ item.Title }}</h3>
        <p>{{ item.Description }}</p>
    {% endfor %}
{% endarchiveList %}

If you want to exclude certain recommended attribute content, you can use itexcludeFlagIf you need to display the recommended attribute tag of the document itself in the list, you need to setshowFlagthe parameter totrue.

Flexible sorting and quantity control

archiveListTags allow you to sort and limit the number of documents in the list to meet the display needs of different scenarios:

  • Sorting method (order): You can sort documents by ID (such asid descDisplay the latest), views(views descShow the most popular) or custom sorting in the background(sort desc) to arrange the documents.
  • Show the number(limit): In addition to specifying a fixed number to display (such aslimit="10"), you can also use the offset mode (such aslimit="2,10"This indicates displaying 10 items starting from the second one, which is very useful in special layout or step-by-step loading scenarios.

For example, to display the top 5 articles with the most views:

{% archiveList topViewsArticles with moduleId="1" order="views desc" limit="5" %}
    {% for item in topViewsArticles %}
        <li>{{ item.Title }} (浏览量:{{ item.Views }})</li>
    {% endfor %}
{% endarchiveList %}

Combine custom model parameters for filtering:archiveFilters

For some more complex filtering needs, especially when you have defined many custom fields in your content model (such as the 'house type', 'area', 'price range' on a real estate website),archiveFiltersTags are particularly important.

archiveFiltersTags are specifically used to generate filtering conditions based on custom parameters of the content model. It is usually associated witharchiveListlabel'stype="page"(Pagination list) mode in conjunction with. By using it, you can build a user-friendly filtering interface that allows users to dynamically filter document lists based on multiple conditions.

{% archiveFilters filterOptions with moduleId="2" allText="全部" %}
    {% for filterItem in filterOptions %}
        <div class="filter-group">
            <span>{{ filterItem.Name }}:</span>
            {% for option in filterItem.Items %}
                <a href="{{ option.Link }}" class="{% if option.IsCurrent %}active{% endif %}">{{ option.Label }}</a>
            {% endfor %}
        </div>
    {% endfor %}
{% endarchiveFilters %}

{% archiveList filteredProducts with type="page" moduleId="2" limit="12" %}
    {% for product in filteredProducts %}
        {# 展示产品详情 #}
        <h3>{{ product.Title }}</h3>
        <p>价格: {{ product.Price }}</p>
    {% endfor %}
{% endarchiveList %}

here,filterOptionsContains all filterable parameters and their values, you can iterate through them to generate the front-end filter links. When users click these links, the page URL will carry the corresponding query parameters,archiveListcan automatically identify and display matching documents.

Implement pagination display

When the content of the document list is too much, pagination is an essential function. ThearchiveListlabel'stypethe parameter to"page"After that, you can combinepaginationTags to generate page navigation.

{% archiveList pagedArticles with type="page" moduleId="1" limit="10" %}
    {% for item in pagedArticles %}
        <li><a href="{{ item.Link }}">{{ item.Title }}</a></li>
    {% endfor %}
{% endarchiveList %}

{% pagination pages with show="5" %}
    <nav class="pagination">
        {% if pages.PrevPage %}<a href="{{ pages.PrevPage.Link }}">上一页</a>{% endif %}
        {% for page in pages.Pages %}
            <a href="{{ page.Link }}" class="{% if page.IsCurrent %}active{% endif %}">{{ page.Name }}</a>
        {% endfor %}
        {% if pages.NextPage %}<a href="{{ pages.NextPage.Link }}">下一页</a>{% endif %}
    </nav>
{% endpagination %}

paginationThe tag provides complete pagination data including home page, previous page, next page, last page, and middle page numbers, you can freely build the style of pagination navigation as needed.

Display of multiple lists within the page

It is also a common requirement to display a list of documents with different filtering conditions on a single page.For example, a homepage may need independent modules such as 'Latest Articles', 'Hot Products', and 'Recommended Services'.At this time, you just need to use multiplearchiveListTags, and define different variable names for each tag (for examplelatestArticles/hotProducts/featuredServices), then set their filtering conditions separately.

<h2>最新文章</h2>
{% archiveList latestArticles with moduleId="1" order="id desc" limit="5" %}
    {# 循环展示最新文章 #}
{% endarchiveList %}

<h2>热门产品</h2>
{% archiveList hotProducts with moduleId="2" order="views desc" limit="4" %}
    {# 循环展示热门产品 #}
{% endarchiveList %}

By combining these tags and parameters flexibly, you can build a highly customized, feature-rich document list display scheme in AnQi CMS, thereby better organizing and presenting your website content.


Frequently Asked Questions (FAQ)

  1. Can I display a document list from different content models (such as articles and products) on the same page?Of course you can. You just need to use multiple in the page template.archiveListLabel, specify different for each listmoduleIdParameters, and use different variable names to receive data, for example `{% archiveList articles with moduleId="

Related articles

How to get and display all the content and associated images of a specific single page?

In Anqi CMS, a single page is an important part of the website content structure, such as "About Us", "Contact Information", and so on.Effectively acquire and display all the content of these single pages and associated images, which is crucial for the communication and visual expression of the website.Aanqi CMS provides an intuitive backend management and flexible template tags, making this process very convenient. ### Easily set up single page content and images in the background First, we need to create and edit single page content in the Anqi CMS backend management system. This is usually performed under the 'Page Resources' section in the 'Page Management' module

2025-11-08

How to display all or part of a single-page list on a website?

In website operations, we often need to display some independent, fixed-content pages, such as 'About Us', 'Contact Information', or some policy descriptions, etc.In Anqi CMS, these are called "single pages". Effective management and presentation of these single pages not only makes the website structure clearer but also enhances the user experience.Next, we will discuss how to flexibly display all or part of a single-page list on a website.### **Understanding the Creation and Management of Single Pages (Backend Operations)** Before Starting the Frontend Display

2025-11-08

How to retrieve and display detailed information of a specific category (such as description, Banner image)?

In Anqi CMS, it is crucial to flexibly obtain and display detailed information about categories, such as descriptions, Banner images, or thumbnails, which is essential for building a website rich in content and visually appealing.Whether it is necessary to display a brief introduction on the category list page or to reference the promotional picture of a specific category on a specific page, Anqi CMS provides intuitive and powerful template tags to help you meet these needs. To get detailed information about the category, we mainly rely on the `categoryDetail` template tag.This tag is specifically designed to extract data for each category

2025-11-08

How to display a category list based on content model or parent-child relationship?

AnQi CMS is an efficient enterprise-level content management system that provides great flexibility in content organization and display.For many websites, how to display a category list based on different content models or the hierarchical relationship of categories is a very common and important need.This concerns not only the organization structure of the website content, but also directly affects the user experience and SEO effect.In Anqi CMS, implementing such a display is not complicated.The built-in template tags provide us with powerful functions, allowing us to easily control the output of the classification list

2025-11-08

How to display the complete article content on the article detail page, including lazy-loaded images?

How to elegantly display full content and lazy loading images on article detail pages in AnQi CMS In website content operations, the article detail page is an important touchpoint for users to obtain information and gain a deeper understanding of brands and products.A well-designed, fast-loading, and comprehensive article detail page that can greatly enhance user experience and effectively assist in SEO optimization.For users who use Anqi CMS, taking full advantage of its powerful template tag system can easily realize the complete presentation of article content, and combine modern web technologies to implement lazy loading of images, making your website both beautiful and efficient.###

2025-11-08

How to display mathematical formulas and flowcharts with Markdown in AnQiCMS?

In content operations, sometimes we need to display complex mathematical formulas or clear flowcharts, especially in technical articles, data reports, or educational content.AnQiCMS with its powerful Markdown editor, provides us with the convenience to meet this requirement.By simple configuration and importing the necessary library files, you can perfectly present these professional contents on the website front-end.### Enable AnQiCMS Markdown Editor Firstly, let AnQiCMS recognize and handle Markdown formatted content

2025-11-08

How to display the links to the previous and next articles on the document detail page?

When browsing website content, users often want to be able to navigate easily between related articles.For example, after reading a news article or tutorial, you can quickly click to go to the "previous" or "next" article to maintain the continuity of reading.This not only improves user experience and reduces the bounce rate, but also has a positive effect on the internal link structure of the website and search engine optimization (SEO).AnQiCMS (AnQiCMS) is an efficient content management system that provides a very simple and intuitive way to implement this function.We do not need complex backend programming

2025-11-08

How to display a list of related articles below the article detail page?

In website operation, the list of "related articles" at the bottom of the article detail page is an important function to enhance user experience, increase page views (PV), and prolong the time users stay on the site.It can guide users to discover more interesting content, thereby enhancing the overall stickiness of the website, and also has a positive effect on search engine optimization (SEO).To implement this feature in AnQi CMS, it benefits from its flexible template system and powerful tag functions, making the entire process intuitive and efficient.### One, understand the call mechanism of "related articles" The template tags of AnQi CMS are the core of realizing various functions

2025-11-08