How to filter and display a list of documents with specific titles or categories in content management?

Calendar 👁️ 67

Today, as content management is increasingly becoming a core competitive force for corporate websites, AnQiCMS (AnQiCMS) helps us easily handle massive amounts of content with its flexible and efficient features.When you need to accurately filter and display a list of documents with specific titles, categories, or attributes, AnQiCMS provides intuitive and powerful template tags to make this process simple and efficient.

Core tool:archiveListTag Overview

To display the document list on the website front-end, we mainly use the core template tags of AnQiCMSarchiveList. This tag is powerful, able to filter content based on various conditions and display it in a list or paginated form. It supports multiple parameters to finely control the presentation of content.

usually, you will see such a basic structure to call the document list:

{% archiveList archives with type="list" limit="10" %}
    {% for item in archives %}
        {# 在这里展示每个文档的详细信息 #}
    {% empty %}
        <p>该列表没有任何内容。</p>
    {% endfor %}
{% endarchiveList %}

In this code block,archivesis the variable name we specify for the document list, you can name it according to your preference.forThe loop will iterate over each document in the list (we call ititem), and display its content within the loop. If the list is empty,emptythe content within the tags will be displayed.

Based on category and content model filtering

Flexible content model design of AnQiCMS, allowing us to create independent models for different types of content (such as articles, products, events, etc.) and establish a classification system for each model. When you need to filter documents under a specific category,archiveListlabel'scategoryIdandmoduleIdParameters are particularly important.

  • Filter by content model (moduleId): If you want to display all documents under the "Article Model" and ignore the content of the "Product Model", you can setmoduleId="1"(Assuming the article model ID is 1). This is very useful for distinguishing content across models when displaying.

  • Filter by category (categoryId)When you need to display documents under a specific category, just provide the ID of that category. For example,categoryId="10"The documents under the category with ID 10 will be displayed. If you want to display the content of multiple categories at the same time, you can pass multiple IDs separated by commas, for examplecategoryId="10,12,15".

  • Exclude a specific category (excludeCategoryId) Conversely, if you want to display all documents under a model except for a specific category, you can useexcludeCategoryId="10"to exclude category with ID 10.

  • Containing subcategory (child)By default, when you specify a category ID,archiveListIt will automatically include all documents under its subcategories. If you only want to display the documents of the current specified category without including its subcategories, you canchildthe parameter tofalse, that ischild=false.

Filter documents based on document attributes

In addition to categories, AnQiCMS also allows you to set various 'recommended properties' (Flag) for documents, which are like putting special tags on documents, such as 'headlines', 'recommended', 'slides', etc. UsingflagParameters, you can easily filter out documents with specific properties:

  • Specify recommended attributes (flag): For example, to filter out all documents marked as "Top News", you can useflag="h". The document supports the following attribute values:h(Headline),c(Recommended),f(Slide),a(Special recommendation),s(Scrolling)、“p(Image)、“j(Jumping) Please flexibly combine according to your needs。“

  • Exclude recommended attributes (excludeFlag)If you do not want certain attributes of documents to be displayed in the list, you can useexcludeFlagparameters, for exampleexcludeFlag="s"Documents marked as "scrolling" will be excluded.

  • Specify the author or parent document (userId,parentId): For multi-author websites or documents with hierarchical relationships (such as subordinate documents), you can also filter specific author's published documents or the sub-content of specific superior documents byuserIdorparentIdparameters.

Implement keyword search and advanced dynamic filtering

In many scenarios, visitors need to search for content by entering keywords or filter based on multiple custom conditions.

  • Keyword search (q)When you need to create a search results page,archiveListlabel'sqthe parameters are very useful. Usually, we will list the typetypeis set topagesuch that the keywords entered by the user in the search box (via the URL parameters) will be automaticallyqtransmittedarchiveListCapture and use for search. For example, after a search form is submitted, the URL may be/search?q=安企CMSin your template.archiveListIt will automatically filter based on “AnQi CMS”.

  • Advanced dynamic filtering (archiveFilters)Imagine a real estate website where users might need to filter listings based on multiple conditions such as "house type", "area", "price range", and so on. At this point,archiveFiltersLabels can be put to use. It will automatically generate a series of filtering conditions and their corresponding links based on the custom fields you configure for the content model. You just need toarchiveFilterswith the tag andarchiveListTag (set as)type="page"Use them together to provide users with a powerful dynamic filtering experience.

    In the template, you can use it like thisarchiveFilters:

    {% archiveFilters filters with moduleId="1" allText="不限" %}
        {% for item in filters %}
        <ul>
            <li>{{ item.Name }}: </li>
            {% for val in item.Items %}
            <li class="{% if val.IsCurrent %}active{% endif %}"><a href="{{ val.Link }}">{{ val.Label }}</a></li>
            {% endfor %}
        </ul>
        {% endfor %}
    {% endarchiveFilters %}
    

    This code will loop through all the filterable parameters (such as "house type") and the specific options under each parameter (such as "residential", "commercial"). When the user clicks on an option, the page URL will automatically include the corresponding filter parameters and byarchiveListLabel capture and apply.

Content display and pagination control

After filtering out the appropriate documents, how to beautifully display them and provide a friendly pagination experience is also important.

  • Details of traversal and display contentInarchiveListofforthe loop,itemThe variable represents the current document being processed. You canitem.TitleGet the document title,item.LinkGet the document link,item.DescriptionGet the document summary,item.ThumbRetrieve document thumbnails and the like. For time, you can use{{ stampToDate(item.CreatedTime, "2006-01-02") }}to format the display. If the document summary or content contains HTML tags, remember to add|safea filter to avoid escaping.

    For example: “`twig {% for item in archives %}

    <h2><a href="{{ item.Link }}">{{ item.Title }}</a></h2>
    {% if item.Thumb %}
        <img src="{{ item.Thumb }}" alt="{{ item.Title }}">
    {% endif %}
    <p>{{ item.Description|safe }}</p>
    <footer>
        <span>发布日期:{{ stampToDate(item.CreatedTime, "2006年01月02日") }}</span>
        <span>浏览量:{{ item.Views }}</span>
        {% if item.CategoryId %}
            <span>分类:{% categoryDetail with name="Title" id=item.CategoryId %}</span>
        {% endif %}
    </footer>
    

    <article>

Related articles

How to display the list of all documents under a specific Tag?

In Anqi CMS, managing and displaying content, the tag (Tag) is undoubtedly a very flexible and powerful tool.It can help us classify content in multiple dimensions, not only making it convenient for visitors to find topics of interest, but also effectively improving the website's SEO performance.Today, let's delve deeply into how to elegantly display all document lists under a specific tag (Tag) on your website. ### Backend preparation: Ensure that the tag settings are in place Before starting the frontend display, we need to make sure that the backend tag settings are complete and standardized. First

2025-11-08

How to configure and display the article Tag tag list in AnQi CMS?

In website operation, Tag tags (also known as keyword tags) are a very practical way to organize content, which can help users quickly find related content and also improve the SEO effect of the website content.AnQiCMS (AnQiCMS) provides a comprehensive Tag label configuration and display function, making it easy and efficient to manage and display these tags.Below, let's take a detailed look at how to set up and use these tags in AnQiCMS.--- ### One, background configuration and management of article Tag label In AnQiCMS

2025-11-08

How to display the user message or article comment list and handle the review status?

In website operation, user comments and article reviews are an important part of promoting interaction and enhancing content value.For users of Anqi CMS, it is crucial to display user-generated content reasonably and manage their review status effectively to ensure the quality of website content and user experience.We will discuss in detail how to achieve this goal in Anqi CMS. ### Learn about comment and message management in Anqi CMS Anqi CMS provides users with convenient content comment and website message management features.In the background management interface

2025-11-08

how to display the captcha in the message or comment function?

In website operation, the message and comment functions are important channels for interaction with users, but they often become hotbeds of spam and malicious flooding.It is particularly important to add captcha to these interactive functions to maintain a clean and high-quality communication environment.AnQi CMS understands this and provides a convenient solution for it.How can you display a captcha in the Anqi CMS message or comment feature to effectively resist spam?This mainly consists of two core steps: first, enable the captcha feature in the background, and then integrate the captcha element into the front-end template.### Step 1

2025-11-08

How to display Markdown formatted content on a front-end page (including mathematical formulas and flowcharts)?

AnQi CMS provides users with powerful and flexible content management capabilities, among which the support for Markdown format greatly improves the efficiency of content creators.Whether it is necessary to display complex mathematical formulas in technical articles or to present clear flowcharts in product documents, Anqi CMS can help you beautifully present these contents on the frontend page. To achieve this goal, we need to follow several steps, from backend settings to frontend template adjustments, to ensure that the content is correctly parsed and rendered.### First step: Enable Markdown editor in the background First

2025-11-08

How to configure URL rewrite rules in AnQi CMS to optimize link display?

The website link, like the door number of a website, a clear and regular door number is not only convenient for visitors to remember and share, but also a key to understanding the structure of the website content, improving the efficiency of inclusion and ranking for search engines.This technique of optimizing dynamic links to look like static files is called 'pseudo-static'.The Aanqi CMS thoroughly understands this, providing users with powerful and flexible static configuration capabilities, aimed at helping websites perform better in search engines while improving the user browsing experience.The value of pseudo-static: Why can't it be ignored?in website operation

2025-11-08

How to avoid XSS attacks and safely display HTML content when outputting?

In website content management, ensuring the safe display of information, especially in preventing cross-site scripting (XSS) attacks, is an important issue that every content creator and website administrator must face.XSS attacks exploit vulnerabilities in websites, injecting malicious code into web pages. When other users visit the web page, the malicious code will execute on the user's browser, potentially stealing user information, hijacking sessions, or even tampering with web content, posing serious harm to the website and users.Fortunately, AnQiCMS has fully considered content security from the beginning of its design, providing us with multiple protective measures

2025-11-08

How to truncate long text content and display an ellipsis?

In the operation of daily websites, we often encounter such situations: the content of the article detail page is rich, but the list page or recommendation module needs to display a concise version of the content for the sake of page layout, usually by truncating a part of the text and adding an ellipsis at the end.AnQi CMS understands the importance of content display and provides very convenient and powerful tools to handle such needs.Let's take a look at how to elegantly implement the truncation of long text content and display an ellipsis in Anqi CMS, making the website interface both beautiful and professional.The need and value of content truncation in many display scenarios

2025-11-08