How to call and display a document list in a template, and perform sorting and filtering?

Calendar 👁️ 74

Manage and display website content in Anqi CMS, especially document lists, is a very common need in daily operations.AnQi CMS provides powerful and flexible template tags, allowing us to easily call and display these contents on the website front-end, and sort and filter them as needed.This article will delve into how to use the template function of Anqi CMS to achieve these goals, making your website content more attractive.

Core function:archiveListTag - Display the basic content of the document

To display the document list, we mainly use the Anqi CMS'sarchiveListtag. This tag is the core of calling document data, which can retrieve the documents you want to display according to various conditions.

Usually, you would use it like this in a template file (such as a list page or home page):

{% archiveList archives with type="list" limit="10" %}
    {% for item in archives %}
    <li>
        <a href="{{ item.Link }}">
            <h3>{{ item.Title }}</h3>
            <p>{{ item.Description|truncatechars:100 }}</p>
            <div>
                <span>发布日期: {{ stampToDate(item.CreatedTime, "2006-01-02") }}</span>
                <span>浏览量: {{ item.Views }}</span>
            </div>
        </a>
        {% if item.Thumb %}
            <img src="{{ item.Thumb }}" alt="{{ item.Title }}">
        {% endif %}
    </li>
    {% empty %}
    <li>暂时没有文档内容。</li>
    {% endfor %}
{% endarchiveList %}

In this code block,archiveListThe tag assigns the set of retrieved documents toarchivesthis variable. Then, we use{% for item in archives %}Loop through each document and displayitem.Title/item.Link/item.Descriptionfields to show the document title, link, and summary.stampToDateIt is a very practical function that is used to format timestamps into readable dates. If there is no documentation,{% empty %}the block will display the preset prompt information.

archiveListThe tag supports a series of parameters that allow you to precisely control which documents to display and how they are displayed:

  • moduleId: Specify the ID of the content model (for example, articles are usually 1, products might be 2), make sure you are calling the correct type of content.
  • categoryId: Filter documents based on category ID, you can specify a single ID, or use commas to separate multiple IDs, or even usechild=trueorchild=falseto determine whether to include documents from subcategories.
  • limit: Controls the number of documents displayed. For examplelimit="10"Displays the most recent 10 documents. It also supportsoffsetpattern, such aslimit="2,10"It means to get 10 data items starting from the 2nd one.
  • type: This is a very critical parameter, defining the type of the list.
    • type="list"Used for simple list display, affected bylimitParameter limit.
    • type="page"Used for lists that require pagination, must be used with.paginationlabel usage
    • type="related"Used to display related documents, usually on the document detail page.
  • order: Used to specify the document sorting rules.

Masterfully control: Sorting of document lists

Anqi CMS makes sorting documents effortless, byarchiveListlabel'sorderParameters, you can sort documents according to multiple dimensions.

  • Sort by latest release: Use.order="id desc"Will place the latest documents at the top.
  • Sorted by views:order="views desc"Can prioritize documents with the highest number of views for recommended popular content.
  • Sorted by custom order in the background.If you have manually sorted the documents in the background,order="sort desc"Will be displayed in the order you customize.

For example, to display the top five articles with the highest views under a certain category, you can write it like this:

{% archiveList hotArticles with categoryId="1" order="views desc" limit="5" %}
    <h4>热门文章</h4>
    <ul>
    {% for item in hotArticles %}
        <li><a href="{{ item.Link }}">{{ item.Title }} ({{ item.Views }}次浏览)</a></li>
    {% endfor %}
    </ul>
{% endarchiveList %}

Accurate positioning: filtering the document list

Filtering is an indispensable part of content operation, AnQi CMS provides various filtering methods to help you present the most suitable content to users.

  1. Filter by categoryThis is the most basic filtering method. BycategoryId="1"You can display all documents under the category with ID 1. If you want to include subcategories, you can add extra ones.child=true.

  2. Filter by recommended attributes: Anqi CMS allows you to set various recommended properties for documents, such as 'Headline', 'Recommended', 'Slideshow', and others. Useflagparameters to call documents with these specific properties, such asflag="h"Call the headline article,flag="c"Call the recommended article.

  3. Keyword search filtering: When you need to add a search function to the list page,qThe parameter is very useful. It will automatically read the URL in.qQuery parameters act as search keywords to match document titles. You can search on the page.archiveListOmitted in the tagqParameters, the system will automatically capture the search terms in the URL.

  4. Custom parameter filtering:archiveFiltersTagWhen your document model includes custom fields (such as "color", "size", "layout", etc.) and you want users to be able to filter through these custom fields,archiveFiltersTags are particularly powerful.

    It generates a list of selectable filter conditions, each with corresponding links that can trigger the filter when clicked.

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

    here,filtersThe variable includes all the available custom parameters and their options.item.NameIs the parameter name (such as “Type of house”),item.ItemsIt is all the optional values under this parameter (such as "One-bedroom", "Two-bedroom"),val.LinkIt provides a URL for filtering after clicking.val.IsCurrentIt determines whether the current option is selected.

A smooth experience: Implement the pagination function of the document list

Pagination is an essential function for websites with a large amount of content. The pagination implementation of Anqi CMS is very simple, you just need to cooperatearchiveListoftype="page"Parameters andpaginationTag it and it is.

  1. settingarchiveListFor pagination modeEnsure that inarchiveListSet in the labeltype="page"so that it can respond to pagination requests and return the data of the current page.
  2. **Usepagination

Related articles

How to retrieve and display the complete content and images of a specific single page?

Use AnQiCMS to manage and display website content, especially when dealing with independent and rich single-page content such as "About Us" and "Contact Information", its flexibility and powerful functions are particularly prominent.We often need to present the text, images, and even image sets of these pages in their entirety on the website, and AnQiCMS provides a very intuitive way to achieve this. Let's explore together how to retrieve and display the complete content and images of a specific single page in AnQiCMS, making your website content more vivid and diverse.## Content Creation

2025-11-08

How to list and display the titles and links of all single pages?

AnQi CMS provides a user-friendly and powerful content management system, where the single-page feature is an ideal choice for building independent pages such as "About Us", "Contact Information", or "Privacy Policy".When you need to display the titles and links of these single-page in a centralized position on the website, such as in the footer navigation, sidebar, or a dedicated page index, the template tags of AnQiCMS can help you easily achieve this.In the AnQiCMS backend, single-page content is created and maintained under "Page Resources" > "Page Management".You can easily add to the website like 'About Us'

2025-11-08

How to retrieve and display detailed information for a specific category, such as the category logo and introduction?

In website operation, a clear and informative classification display is the key to attracting visitors, improving user experience, and optimizing search engine rankings.AnQiCMS provides a user-friendly and powerful template tag system that allows you to flexibly obtain and display detailed information of various categories on your website, such as category logo and introduction, thereby creating a more attractive content layout. ### Understand Category Information Management and Configuration Category information management is very convenient in the Anqi CMS backend.When you enter the 'Content Management' under 'Document Category' to add or edit

2025-11-08

How to display category lists on the homepage or category pages?

In Anqi CMS, managing and displaying the category list is the core of website content organization.It is crucial to clearly display the classification structure for optimizing user navigation experience or improving search engine crawling efficiency.The Anqi CMS provides concise and powerful template tags, allowing you to easily display your content categories on the homepage, category pages, or any place you need.### Understanding Core: `categoryList` Tag In the AnQiCMS template system, the main tag used to retrieve the category list is `categoryList`

2025-11-08

How to display the link to the previous and next article on the article detail page?

It is an important link in the article detail page of AnQi CMS to display "Previous" and "Next" navigation links, which helps improve the user experience and the internal link structure of the website.This not only guides readers to continue browsing related content and extend their stay time, but also helps search engines better understand the relevance between website content, which has a positive effect on SEO optimization.AnQi CMS provides a user-friendly and powerful template tag system

2025-11-08

How to get and display a list of recommended articles related to the current article?

In website operation, when we have worked hard to create an article, we naturally hope that it can be seen by more readers and guide them to explore more exciting content.On the bottom or sidebar of the article detail page, cleverly display recommended content related to the current article, which can not only significantly improve the depth and dwell time of users' reading, but also bring many benefits to search engine optimization (SEO).AnQiCMS (AnQiCMS) fully understands this need and provides extremely convenient and powerful tags to help us easily achieve this goal.### Cleverly Utilize `archiveList`

2025-11-08

How to display the content of custom fields (such as author, source) on the article detail page?

In website operation, the article detail page is not only a place to display the core content, but also a key to convey additional information, enhance professionalism, and improve user experience.In addition to the title and body, we often need to display some custom fields on the article detail page, such as author, source, publisher, product model, and so on.This information not only enriches the content of the article, but also helps to enhance the authority and credibility of the website, even having a positive impact on SEO optimization and user decision-making.AnQiCMS (AnQiCMS) is designed with a flexible content model, making the display of these custom fields very intuitive and powerful

2025-11-08

How to use Tag tags to associate and display related content on the front end?

In Anqi CMS, content organization and association is the key to enhancing website value, optimizing user experience, and improving search engine performance.In addition to the traditional classification structure, we also have a very powerful and flexible tool - Tag tag.It is like a 'living index' of content, which helps us to connect scattered content in multiple dimensions, making it easier for users to find the information they are interested in.Today, let's talk about how to make full use of Tag tags on the front end to associate and display our wonderful content.### Tag label: Flexible content association bridge Different from a strict classification system

2025-11-08