How to efficiently organize and display a large amount of content on a website, and ensure that users can quickly find the information they need, is the key to improving user experience and content value.AnQiCMS (AnQiCMS) provides powerful content management functions, among which the flexible filtering mechanism of the article list can help us easily achieve accurate content presentation.This article will discuss in detail how to filter and display a list of articles in the Aanqi CMS by category, tags, and recommended attributes.


Precisely present: How does the Anqi CMS article list filter and display by category, tag, or recommended attribute?

The core value of the content management system lies in the organization and presentation of content.When we accumulate a large amount of articles, products, or other content, if we cannot classify and filter them effectively, it will be difficult for users to quickly find the information they are interested in.This provides intuitive and powerful template tags for AnQi CMS, allowing us to flexibly display content lists based on various dimensions such as categories, tags, and recommended attributes.

core tools:archiveListDocument list label

In the template system of Anqi CMS,archiveListLabels are the foundation for displaying article lists.It provides a rich set of parameters, allowing us to query and output content based on a variety of conditions.archiveListCan do everything.

In the template file,archiveListLabels are usually used withforLoops to iterate over each article found. For example:

{% archiveList archives with moduleId="1" type="page" limit="10" %}
    {% for item in archives %}
        <li><a href="{{item.Link}}">{{item.Title}}</a></li>
    {% empty %}
        <li>暂无内容</li>
    {% endfor %}
{% endarchiveList %}

The above code demonstrates a basic article list,moduleId="1"usually represents the article model (the specific ID needs to be confirmed according to the backend settings),type="page"indicates that the list supports pagination,limit="10"Then limit the display of 10 articles per page.

Next, we will specifically explain how to applyarchiveListTags and their auxiliary tags.

Method one: Filter content by category

Categories are one of the most basic ways to organize content. In the AnQi CMS, we can specify the category of an article, and display the content based on these categories on the front page.

To filter articles by category,archiveListTags providecategoryIdparameters. You can directly specify one or more category IDs to get the articles under them.

For example, if we want to display all articles under the category with ID 1, we can write it like this:

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

If you need to display articles for multiple categories (for example, categories with IDs 1, 2, 3), you can separate the category IDs with commas:categoryId="1,2,3". In addition,childThe parameter (default is true) controls whether to include articles of subcategories. If you only want to display the current category without including its subcategories, you can setchild=false.

通常,为了让用户在前台方便地选择分类,我们还需要结合 EnglishcategoryList标签来展示所有可点击的分类导航: English

{% categoryList categories with moduleId="1" parentId="0" %}
    {% for item in categories %}
        <a href="{{item.Link}}">{{item.Title}}</a>
    {% endfor %}
{% endcategoryList %}

After the user clicks the category link, the pseudo-static rules of the security CMS will automatically parse the category ID or alias and pass it to the page template,archiveListLabel can automatically identify the classification ID of the current page, no manual setting is requiredcategoryId.

Method two: Filter content by label

Tags provide a more flexible way to associate content, not limited to a fixed hierarchical structure, and can link articles of different categories and models through a common topic.

AnQi CMS providestagDataListLabel is used to retrieve the list of articles under a specified label.

For example, to display all articles under the label with ID 5:

{% tagDataList archives with tagId="5" type="page" limit="10" %}
    {% for item in archives %}
        <li><a href="{{item.Link}}">{{item.Title}}</a></li>
    {% endfor %}
{% endtagDataList %}

To get all tags or the associated tags of the current article, you can usetagListtags. This is very useful for building a hot tag cloud or displaying related tags on the article detail page:

{% tagList tags with limit="10" %}
    {% for item in tags %}
        <a href="{{item.Link}}">{{item.Title}}</a>
    {% endfor %}
{% endtagList %}

Similar to categories, when the user clicks on the tag link,tagDataListtags can also automatically identify the tag ID of the current page.

Method three: filter content by recommended attributes

Recommended properties are a special filtering mechanism that allows operators to tag articles withThe Anqi CMS backend provides various recommended attributes (such as: headline [h], recommended [c], slider [f], etc.).

To filter articles by recommended attributes, just inarchiveListthe label useflagParameter.

For example, to display all articles marked as "recommended":

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

You can choose different attribute letters based on your actual needs (such asflag="h"represents the headlineflag="f"Representing slides.)