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="