How to build a list page of articles with filtering conditions, such as filtering by custom properties?

Calendar 👁️ 74

As an experienced CMS website operation person, I know how to meet user needs through refined content presentation.Build a list page of articles with filtering conditions, especially filtering on custom properties, is an important means to improve user experience and help users quickly find the information they need.AnQi CMS with its flexible content model and powerful template tags makes this process efficient and intuitive.

Build a list page of articles filtered by custom attributes, mainly involving the following core steps: First, define and configure these custom attributes in the background management system; second, use the tags provided by Anqi CMS in the front-end template to generate the user interface for filtering conditions; finally, display the filtered content through the article list tag and combine it with pagination to provide a complete browsing experience.

Configure custom content model and filter properties

To implement article filtering by custom attributes, the first step is to define these custom attributes in the Anqi CMS backend.The flexible content model of AnQi CMS is the foundation for this feature.

You need to navigate to the "Content Management" module on the backend and then click on the "Content Model".Here, you can choose to edit an existing content model (such as "article model") or create a new one to meet specific business needs.In the content model editing interface, you can add 'Custom fields of content model'.These fields will serve as additional attributes for your article.

Add custom fields and clearly specify the "parameter name" as the display and management name in the background, and the "reference field" as the unique identifier used in the front-end template (it is recommended to use English lowercase letters, such ashouseTypeorregion), and the most important "field type". To implement the filtering function, we usually choose among "single selection", "multiple selection", or "drop-down selection".When selecting these types, you need to enter all possible options line by line in the "default value" (for example, for house types, you can enter "residential", "shop", "apartment", and so on;For the area, you can enter 'downtown', 'suburb', 'development zone', etc.).These predefined options will be used directly for generating front-end filter conditions.After defining the field, save the content model and select or fill in the corresponding custom attribute values when publishing or editing an article.

Build the user interface for front-end filtering conditions

After defining custom properties and adding the corresponding data to the article, we need to build a filtering function in the article list page template. Anqi CMS providesarchiveFiltersLabels for conveniently generating these filtering conditions.

Firstly, you need to determine the template file corresponding to your article list page. According to Anqi CMS's convention of 'template directory and template', it is usually located at/template/您的模板目录/{模型table}/list.htmlThe file. You can use thearchiveFilterstag to get and render the filtering conditions.

For example, if you want to generate a filter condition for a document with model ID 1 (usually the article model), you can do it like thisarchiveFiltersTags:

{# 参数筛选代码区域 #}
<div>
    <div class="filter-title">筛选条件:</div>
    {% archiveFilters filters with moduleId="1" allText="不限" %}
        {% for item in filters %}
        <ul class="filter-group">
            <li class="filter-name">{{item.Name}}: </li>
            {% for val in item.Items %}
            <li class="filter-item {% if val.IsCurrent %}active{% endif %}">
                <a href="{{val.Link}}">{{val.Label}}</a>
            </li>
            {% endfor %}
        </ul>
        {% endfor %}
    {% endarchiveFilters %}
</div>

In this code block,moduleId="1"We specified the filter we want to generate for the article model.allText="不限"It sets the display text for the 'All' option of each filter group.filtersThe variable contains all the custom attribute groups that can be filtered, eachitemRepresents a custom attribute (such as "House Type").item.ItemsThese are all the optional values under the attribute (such as "Residential", "Commercial").val.LinkAn automatic URL with the corresponding filter parameters will be generated, click to submit the filter request.val.IsCurrentIt is used to determine whether the current option is selected, so that it can be highlighted on the interface.Through such a structure, users can clearly see all the filtering dimensions and their optional values, and can filter by clicking on the link.

Display the filtered article list and pagination.

After the filter condition is generated, the next step is to display the actual list of articles. It is AnQi CMS'sarchiveListTags can intelligently identify the filter parameters in the URL and return the filtered articles accordingly.

In the same list page template, immediately following the filter conditions, you can addarchiveListLabels to display articles. When the user clicks the filter link, the page URL will carry custom attribute parameters,archiveListLabels will automatically read these parameters and filter the content without the need for additional coding processing:

{# 文章列表区域 #}
<div class="article-list-container">
{% archiveList archives with moduleId="1" type="page" limit="10" %}
    {% for item in archives %}
    <div class="article-item">
        <a href="{{item.Link}}">
            <h3 class="article-title">{{item.Title}}</h3>
            {% if item.Thumb %}
            <img class="article-thumb" alt="{{item.Title}}" src="{{item.Thumb}}">
            {% endif %}
            <p class="article-description">{{item.Description}}</p>
            <div class="article-meta">
                <span class="category-name">所属分类:{% categoryDetail with name="Title" id=item.CategoryId %}</span>
                <span class="publish-date">发布日期:{{stampToDate(item.CreatedTime, "2006-01-02")}}</span>
                <span class="views-count">阅读量:{{item.Views}}</span>
            </div>
        </a>
    </div>
    {% empty %}
    <div class="no-content-message">
        抱歉,该筛选条件下暂无文章内容。
    </div>
    {% endfor %}
{% endarchiveList %}

    {# 分页代码区域 #}
    <div class="pagination-container">
        {% pagination pages with show="5" %}
            <a class="pagination-link {% if pages.FirstPage.IsCurrent %}active{% endif %}" href="{{pages.FirstPage.Link}}">首页</a>
            {% if pages.PrevPage %}
            <a class="pagination-link" href="{{pages.PrevPage.Link}}">上一页</a>
            {% endif %}
            {% for item in pages.Pages %}
            <a class="pagination-link {% if item.IsCurrent %}active{% endif %}" href="{{item.Link}}">{{item.Name}}</a>
            {% endfor %}
            {% if pages.NextPage %}
            <a class="pagination-link" href="{{pages.NextPage.Link}}">下一页</a>
            {% endif %}
            <a class="pagination-link {% if pages.LastPage.IsCurrent %}active{% endif %}" href="{{pages.LastPage.Link}}">尾页</a>
        {% endpagination %}
    </div>
</div>

InarchiveListTagged,moduleId="1"The article model was specified again.type="page"Indicates that this is a paged list, whilelimit="10"Then, the number of articles displayed per page was set.archivesThe variable contains all the article data on the current page, you can iterate through it and displayitemthe fields to show the article title, link, description, thumbnail, and publication time information.

At the same time, we combined the use ofpaginationtags to generate pagination navigation.pagesThe variable contains all the information needed for pagination, including the total number of pages, the current page, the first page, the last page, the previous page, the next page, and the list of page numbers in the middle.show="5"Parameters control the display quantity of middle page number links. Users can browse through the filtered results using these links.

By following these steps, you will be able to successfully build a feature-rich, user-friendly article list page on the Anqi CMS with custom attribute filtering conditions.This has not only improved the organization of website content, but also greatly improved the efficiency of users in finding information.


Frequently Asked Questions

Q1: But I defined custom properties,archiveFiltersWhy are these filter conditions not displayed in the tag?

A: First make sure that when you add a custom field in the "Content Model", you set its "Field Type" to "Single Selection", "Multiple Selection", or "Dropdown Selection". These three types of data arearchiveFiltersLabels can recognize and generate filtering conditions. Secondly, please confirm that your article has indeed filled in and saved the values of these custom attribute values and thatarchiveFilterslabel'smoduleIdThe parameter matches the model ID of the article you belong to.

Q2: After clicking the link of the filter condition, the page does not change, or the article list does not update according to the filter conditions. How should I investigate?

A: In this case, you need to check a few points. First, confirm that your website's static rule is configured correctly, because filtered links are usually presented in the form of URL query parameters (such as?region=cityCenterIf the pseudo-static configuration is not set up properly, these parameters may not be parsed correctly. You can checkhelp-plugin-rewrite.mdconfirm the pseudo-static rules in the document. Next, make sure that inarchiveListTagged,typethe parameter to"page", because it is only available in pagination mode,archiveListIt will automatically handle the filtering parameters in the URL. Finally, if the problem still exists, check the network requests in the browser developer tools to see if the filtering link is sent correctly and if the backend returns data as expected.

Q3: How can the custom filter condition support multiple selections at the same time?

A: Safe CMS ofarchiveFiltersThe filter link generated by the tag will be based on a single value.If you set the field type to 'Multiple Choice' in the content model, the user will usually click on a filter value to apply the condition in the frontend template.In order to implement complex filtering logic similar to 'multiple selection' (for example, to filter both 'residential' and 'apartment'), it usually requires capturing the user's multiple selections on the frontend, then dynamically building a URL with multiple parameters (for example,?houseType=住宅&houseType=公寓), or encode multiple selection values into a single parameter (for example,?houseType=住宅,公寓),then submit it to the background. Security CMS.archiveListThe tag can handle queries with multiple same-named field parameters in the URL. You just need to make sure that the URL format generated by the front-end is correct.

Related articles

How to retrieve and display the custom parameter field value of the article through template tags in AnQiCMS?

In AnQiCMS (AnQiCMS), the custom parameter field provides great flexibility and scalability for website content.As a website operator familiar with AnQi CMS, I am well aware of how to effectively utilize these fields and display them on the website front end to meet diverse content display needs.This article will elaborate on how to use the AnQi CMS template tags to obtain and display the custom parameter field values of the article.### Understanding the customized parameter fields of AnQi CMS AnQi CMS allows users to customize the content model according to business needs

2025-11-06

How to display a list of recommended articles related to the current article content, supporting keyword search or manual association?

As an experienced CMS website operation person in the security industry, I know that high-quality content and accurate recommendations are important for improving user experience and website SEO.In the article detail page, effectively displaying recommended articles related to the current content can not only extend the user's visit time and reduce the bounce rate, but also optimize and improve the page weight and crawling efficiency through internal links.AnQi CMS provides flexible tags, supporting us to build this recommendation list through keywords or manual methods.### Implementing related article recommendations in AnQi CMS AnQi CMS uses a powerful template tag system

2025-11-06

How to get the title, link, and thumbnail of the previous and next articles of the current article?

As an experienced website manager familiar with the operation of Anqi CMS, I fully understand the importance of the details of content presentation to user experience and the overall performance of the website.The front and rear navigation function of the article detail page can not only effectively guide users to continue browsing and reduce the bounce rate, but also is an effective means to enhance the relevance between pages and optimize the internal link structure.An enterprise CMS provides a concise and efficient template tag, allowing us to easily achieve this function.--- ### Enhance Content Coherence: Implement Previous and Next Article Navigation in AnQiCMS In Website Content Operation

2025-11-06

How to implement complete pagination functionality for the article list in AnQiCMS template?

As an expert deeply familiar with the operation of AnQiCMS, I know that a smooth, user-friendly website experience is crucial for attracting and retaining users.The pagination feature of a content list is the cornerstone of any content-intensive website, not only optimizing the user's browsing experience, but also an important aspect of search engine optimization.In AnQiCMS, achieving complete pagination for the article list is efficient and flexible through its powerful template tag system.

2025-11-06

How to display the Tag list of articles in AnQiCMS template and generate links for each Tag?

The generation and display of article Tag list and its links in AnQiCMS template As a website operator who deeply understands the operation of AnQiCMS and has a profound understanding of content operation, I know that article tags (Tags) play a core role in improving content discoverability, optimizing user experience, and strengthening website SEO.Tags can not only help readers find related content quickly, but also provide more rich semantic information for search engines.This article will detail how to efficiently display the tag list in AnQiCMS templates

2025-11-06

How to get the detailed information of a specific Tag, such as Tag name, description, index letter, and Logo?

As an experienced CMS website operator, I am well aware of the importance of content tags (Tags) in website content management and SEO optimization.They can not only help us organize content more flexibly and improve user experience, but are also one of the key factors for search engines to understand the structure of website content.Today, I will delve deeply into how to obtain and display detailed information of specific tags in the Anqi CMS template, including tag names, descriptions, index letters, and Logos, to achieve a more refined front-end display.###

2025-11-06

How to display all articles under a specified Tag with pagination support?

As an experienced security CMS website operations manager, I know that high-quality and easily understandable content is crucial for user experience.Today, we will discuss how to implement the article list display under specified tags in AnQi CMS, and add practical pagination functions. This is of great importance for improving user browsing experience and website SEO. ### Understanding the Importance of Tag Pages In Anqi CMS, tags (Tags) are a powerful content organization tool.They allow us to associate the content of different categories even different models through common themes or keywords

2025-11-06

How to retrieve and display the comment list of an article in AnQiCMS template, including parent and child comments

As a website operator who is deeply familiar with the operation of Anqing CMS, I know that the comment area is an indispensable part of the website content ecosystem. It is not only an important place for user interaction but also an extension and amplification of content value.A lively and well-organized comment section can significantly enhance user loyalty and promote a positive interaction cycle between content creators and readers.

2025-11-06