In the AnQi CMS, flexibly displaying website content is the key to enhancing user experience and meeting operational needs.The system provides powerful and easy-to-use template tags based on the category of the article or the recommended attributes of the content, allowing you to easily customize the display of document lists.

core tools:archiveListDocument list label

In the AnQi CMS, the core tool used to control the display of document lists isarchiveList标签。它允许您根据多种条件来筛选、排序和限制显示的文档数量。通过合理配置这个标签,您可以实现各种复杂的列表展示逻辑。

Display document list by category

The 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 %}

Here are themoduleIdUsed to specify the content model, such as 'article model' usually corresponds to ID 1. If you do not want the list to automatically obtain the current page's category ID, you can exclude it explicitly by settingcategoryId="0"to explicitly exclude.

In addition, sometimes we just want to display a specific category.usingincluding the documents within the category, but not the documents in its subcategories. In this case, you can combine.child="false"parameters to precisely control:

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

filter content based on recommended properties

In addition to categories, AnQi CMS also provides rich recommendation attributes (Flag) for you to mark important or special content, and flexibly display them on the front end. These attributes include头条[h]、Recommended[c]、Slide[f]、Special Recommendation[a]、Scrolling[s]and bolding[h]、Image[p]和 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 itexcludeFlag。And if you need to display the recommended attribute tags of the document itself in the list, you need toshowFlagparameter settingstrue.

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 document ID (such as)id descDisplay the latest), views (views descDisplay the most popular) or custom sorting (from the background)sort desc) to sort the documents.
  • Display number(limit): In addition to specifying a fixed number to display (such as)limit="10"), you can also use the offset pattern (such as)limit="2,10",English from auto.

English from auto.

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

Filter based on custom model parameters:archiveFilters

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

archiveFiltersLabels are specifically used to generate filtering conditions based on custom parameters of the content model. It is usually associated witharchiveListTagstype="page"(Pagination list) mode is used in conjunction. With 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 frontend filter links. When users click these links, the page URL will carry the corresponding query parameters,archiveListThen it can automatically identify and display the matching documents.

Enable pagination display

Pagination is an essential feature when the document list content is extensive. It willarchiveListTagstypeparameter settings"page"After that, you can combinepaginationTag 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 label provides complete pagination data including home page, previous page, next page, last page, and page numbers in the middle, and you can freely build the style of pagination navigation according to your needs.

Page multi-list display inside

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 require independent modules such as 'Latest Articles', 'Hot Products', and 'Recommended Services'.archiveListTags, 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 %}

Through the flexible combination of these tags and parameters, you can build a highly customized and feature-rich document list display scheme in the Anqi CMS, thus better organizing and presenting your website content.


Common Questions (FAQ)

  1. Can I display a list of documents 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 a different one for each listmoduleIdParameter, and use different variable names to receive data, such as `{% archiveList articles with moduleId="