How to filter and display AnQiCMS document list according to category ID and recommendation attributes?

Calendar 👁️ 51

Manage website content in AnQiCMS, often need to display document lists based on different conditions.Whether you want to display the latest articles of a specific category on the homepage or highlight some recommended content in the sidebar, the system provides flexible tools to help us achieve this.Today, let's talk about how to cleverly use category ID and recommendation attributes to accurately filter and display the document list you want.

Precise positioning: filter document list by category ID

As your website content becomes richer, a clear classification structure becomes particularly important.AnQiCMS allows you to select a category for each document, which not only facilitates backend management but also provides great flexibility for frontend display.

If you want to display documents under a specific category on a page, such as only displaying the latest news from the "News Center" category, you can usearchiveListThis powerful template tag. This tag has acategoryIdParameters, you just need to pass the target category ID as a value to it. For example, suppose your "news center" category ID is 101, then the code would be like this:

{% archiveList latestNews with categoryId="101" limit="5" %}
    {% for item in latestNews %}
        <a href="{{item.Link}}">{{item.Title}}</a>
        {# 更多文档信息,如发布时间、简介等 #}
    {% endfor %}
{% endarchiveList %}

here,latestNewsThis is a temporary variable name defined for the document list,limit="5"It limited the display to only 5 of the latest documents. In this way, you can easily retrieve the corresponding document content at any location on the website based on the category ID.

It is worth mentioning that if you want to display only the documents under the current category and not include the content of its subcategories, you can further addchild=falseParameter. Conversely, if you want to set all top-level categories, you cancategoryId="0"coordinate withmoduleIdParameters to specify the model type. These detailed controls make the document display more in line with your business needs.

Highlight key points: Filter document list by recommended attributes.

In addition to categorization, AnQiCMS also provides a series of 'recommended attributes', also known as 'Flag'.These properties are like tags for content, helping you to mark important content for highlight display in different areas of the website, such as setting slides, headlines, recommendations, and so on.

When editing documents in the background, you will see an option for "Recommended Properties" where you can select multiple properties such as头条[h]/推荐[c]/幻灯[f]/特荐[a]/滚动[s]/加粗[h]/图片[p]/跳转[j]Each attribute has a corresponding letter identifier. The front-end template calls specific content through these letter identifiers.

You will also use to filter documents with specific recommendation propertiesarchiveListtags, and cooperateflagparameters. For example, if you want to display 3 documents marked as 'recommended' on the homepage, and theirflagLetters arec, the code can be written like this:

{% archiveList featuredArticles with flag="c" limit="3" %}
    {% for item in featuredArticles %}
        <div class="featured-item">
            <img src="{{item.Thumb}}" alt="{{item.Title}}" />
            <h3><a href="{{item.Link}}">{{item.Title}}</a></h3>
            {# 更多详情 #}
        </div>
    {% endfor %}
{% endarchiveList %}

Byflag="c", the system will automatically filter out all documents marked as "recommended". If you want to exclude documents with a specific attribute, you can also useexcludeFlagParameter.

Flexible combination: dual screening of category ID and recommended attributes

The strength of AnQiCMS lies in the flexibility to combine these filtering conditions, realizing a more refined content display.

For example, you may want to display only those articles marked as "headlines" under the "Company News" category. Assuming the category ID for "Company NewshSo your code can be organized like this:

{% archiveList hotCompanyNews with categoryId="102" flag="h" limit="4" order="views desc" %}
    {% for item in hotCompanyNews %}
        <article>
            <h2><a href="{{item.Link}}">{{item.Title}}</a></h2>
            <p>{{item.Description}}</p>
            <span>阅读量:{{item.Views}}</span>
        </article>
    {% endfor %}
{% endarchiveList %}

In this example, we not only combinedcategoryIdandflagand also filtered throughorder="views desc"Sort the results by reading volume from high to low and limit the display to 4 items. If your list needs pagination, you cantypethe parameter topagethen cooperate withpaginationTags used together to provide users with a better browsing experience.

{% archiveList paginatedNews with categoryId="102" flag="h" type="page" limit="10" order="id desc" %}
    {% for item in paginatedNews %}
        <article>
            <h3><a href="{{item.Link}}">{{item.Title}}</a></h3>
            <p>{{item.Description|truncatechars:100}}</p>
            <span>发布日期:{{stampToDate(item.CreatedTime, "2006-01-02")}}</span>
        </article>
    {% empty %}
        <p>该分类下暂无符合条件的文档。</p>
    {% endfor %}

    {# 分页导航 #}
    {% pagination pages with show="5" %}
        {# 首页、上一页、中间页码、下一页、末页的展示逻辑 #}
        {# 例如:#}
        {% for pageItem in pages.Pages %}
            <a class="{% if pageItem.IsCurrent %}active{% endif %}" href="{{pageItem.Link}}">{{pageItem.Name}}</a>
        {% endfor %}
    {% endpagination %}
{% endarchiveList %}

Through these flexible filtering and display methods, AnQiCMS makes content organization and presentation very simple and efficient.You can freely control the display form of each document list based on the website design and operational strategy, providing visitors with more accurate and valuable content.


Frequently Asked Questions (FAQ)

1. How to get the category ID or TagID of the current page to dynamically filter documents?On the category page or Tag page, AnQiCMS will automatically identify the category ID or TagID of the current page. You do not need to specify manually.categoryIdortagIdparameter,archiveListThe label intelligently reads the current context information. For example, on the category list page,{% archiveList archives with type="page" %}it will default to retrieving documents under the current category. If you need to explicitly retrieve the ID, you can use{% categoryDetail with name="Id" %}or{% tagDetail with name="Id" %}.

2. Why is the recommended attribute (Flag) set, but not displayed on the front end?First, check the template code in yourarchiveListHave you used the tag correctly?flagThe parameter, and whether the letter identifier passed matches the one set up on the backend (for example,flag="c"Recommended.Secondly, ensure that your template logic indeed includes a structure for looping through the document list and displaying the content.Finally, if it still does not display, you can check whether the document has been published on the back-end, whether it belongs to the correct category, and whether the recommended properties are correctly checked and saved.

3. How to implement pagination in the document list?To implement pagination in the document list, you need toarchiveListSet in the labeltype="page"and specify the number of documents to display per page, for examplelimit="10"Then, inarchiveListafter the end of thepaginationtag to generate page navigation links.paginationThe label will be based onarchiveListGenerated pagination data, automatically displays home page, previous page, middle page numbers, next page, and end page navigation elements, convenient for users to browse.

Related articles

How to display category introduction, Banner image and thumbnail on AnQiCMS category page?

In website operations, the category page is not only an aggregation of content, but also an important entry for users to understand the website structure and explore specific topics in depth.A well-designed, informative category page that can significantly improve user experience and search engine optimization (SEO) effectiveness.AnQiCMS provides flexible features, allowing us to easily display category descriptions, banner images, and thumbnails on the category page, giving your website's category page a fresh look.Understanding AnQiCMS's category page and template structure In AnQiCMS

2025-11-07

How to display AnQiCMS single-page content and related images?

In website operation, we often need to create some independent pages, such as "About UsThese pages contain relatively fixed content, do not belong to the conventional article or product list, AnQiCMS (AnQiCMS) classifies them as "single page" and provides a very convenient management and display method.Through this system, you can easily publish and update this content, while flexibly controlling their display styles and image presentation.

2025-11-07

How to display custom Banner images on AnQiCMS pages?

In website operation, skillfully using Banner images can not only beautify the page but also effectively convey information and guide user behavior.AnQiCMS as a flexible content management system, provides various ways to display customized Banner images, allowing you to configure them individually according to different pages and needs. ### Flexible Upload and Management of Banner Images Firstly, all images that are going to be used as banners need to be uploaded to the AnQiCMS media library.This is very simple, you can go to the 'Page Resources' menu in the backend

2025-11-07

How to use the pagination tags of AnQiCMS to control the display of list content?

In a content management system, how to effectively display a large amount of information without sacrificing user experience is always a question worth pondering.AnQiCMS provides a powerful and flexible pagination feature that allows website managers to finely control the display of list content, ensuring that the website is both beautiful and efficient.

2025-11-07

How to control the display sorting and pagination of AnQiCMS comment list?

In AnQi CMS, efficiently managing and displaying website comments is crucial for enhancing user interaction and optimizing content experience.The display order and pagination settings of the comment list directly affect the user's experience when browsing comments.This article will give you a detailed explanation of how to accurately control the sorting and pagination of comments in AnQiCMS. ### Understanding the Comment List Template Structure Firstly, we need to clarify the position of the comment list in AnQiCMS.

2025-11-07

How to use AnQiCMS tags to display categories and documents in the navigation menu?

In AnQiCMS, the website's navigation menu is not only an important entry for users to explore content and understand the website structure, but it is also a key for search engines to crawl and understand the website's hierarchical relationships.Using the powerful template tag feature of AnQiCMS, we can easily display categories and documents dynamically in the navigation menu, thus building a beautiful and efficient website navigation. ### One, prepare the background work: build the navigation skeleton Before delving into the template code, we need to make some basic configurations in the AnQiCMS background.In fact, the data that the front-end tags can retrieve and display

2025-11-07

How to configure the page Title, Keywords, Description of AnQiCMS to optimize search engine display?

In website operation, making your content stand out in search engines is a key step to gaining traffic.And the page title (Title), keywords (Keywords), and description (Description), which we often call TDK, are important elements for communicating with search engines.AnQiCMS is a system focused on enterprise content management, fully aware of the value of TDK configuration for SEO, and therefore provides flexible and powerful functions to help us easily optimize the display of our website in search engines.### Why is TDK configuration so important

2025-11-07

How to use the Canonical URL feature of AnQiCMS to avoid content duplication display issues?

In website operations, we often encounter a tricky problem: content duplication.This does not refer to manually copying and pasting the article, but rather to the fact that the same content can be accessed through multiple different URL addresses due to various technical reasons.For search engines, this can cause confusion, as they are not sure which URL is the official version of the content, which may scatter the ranking weight of the page, reduce the efficiency of the crawler, and even affect the overall SEO performance of the website.Luckyly, AnQiCMS provides a powerful and convenient feature——Canonical

2025-11-07