How to implement the AnqiCMS document parameter filtering function on the front page to help users quickly locate content?

Calendar 👁️ 66

How to help users quickly find the information they are interested in on increasingly rich websites is a crucial operational challenge.Users often need to filter content based on specific conditions rather than browsing aimlessly.AnqiCMS provides powerful document parameter filtering functionality, allowing you to easily achieve this goal on the front page, greatly enhancing user experience and content discoverability.

Understand the logic behind the filtering function

Before delving into the front-end implementation, let's briefly understand the design philosophy of the Anqi CMS filtering function. Its core lies in the 'content model' and 'custom fields'.

AnQi CMS allows you to create different content models according to your business needs, such as 'articles', 'products', 'real estate information', and so on.When creating these models, you can add various "custom fields".These custom fields are the basis for our filtering function.For example, if you have a 'real estate information' model, you can add 'house type' (such as residential, commercial), 'house type' (such as one bedroom living room, two bedrooms living room), 'area range', and other fields.

These custom fields not only make your content structure more flexible, but also allow you to fill in detailed attribute information for each document when publishing documents in the background.It is important that when you set the field type to radio, multiple choice, or dropdown, the system will record the option values you set in advance, which are exactly the conditions that users can select when filtering on the front end.

Implement filtering on the front-end page: Core tagsarchiveFilters

When the backend content model and custom fields are properly set up, and the documents are filled with these parameters, we can start working on the front-end page. Anqi CMS provides a very practical template tagarchiveFiltersIt can intelligently obtain all the filterable parameters under the current model and automatically generate filter links.

Imagine that you are running a real estate information website. You want users to be able to filter listings based on conditions such as "house type", "layout", and "area". UsingarchiveFiltersLabel, you can organize your filter area like this:

{# 假设我们正在房产信息模型的列表页,其moduleId为2 #}
<div>
    <h3>房产筛选条件</h3>
    {% archiveFilters filters with moduleId="2" allText="不限" %}
        {% for item in filters %}
        <div class="filter-group">
            <span class="filter-name">{{item.Name}}: </span>
            <ul class="filter-options">
                {% for val in item.Items %}
                <li class="{% if val.IsCurrent %}active{% endif %}">
                    <a href="{{val.Link}}">{{val.Label}}</a>
                </li>
                {% endfor %}
            </ul>
        </div>
        {% endfor %}
    {% endarchiveFilters %}
</div>

Let's break down this code:

  • {% archiveFilters filters with moduleId="2" allText="不限" %}: This is the core label.

    • filtersWe name a variable for the filtered result set, which will be used in the loop later.
    • moduleId="2"Tell the system that we want to retrieve the document parameters under the content model with ID 2 (for example, "real estate information").This is a very critical step, ensuring that the filter only displays parameters related to the current content model.
    • allText="不限"This parameter defines the display text for the "All" or "Unlimited" option in each filter group. The user can click it to clear the current filter conditions.
  • {% for item in filters %}:filtersA variable is an array where eachitemRepresents a filterable parameter group (for example, "House Type").

    • {{item.Name}}This will display the Chinese name you set for the custom field in the background, such as "House Type" or "House Type".
  • {% for val in item.Items %}: Each parameter groupitemThere is anotherItemsArray, where eachvalrepresents a specific filter value under the parameter (such as “Residential”, “Commercial”)}]

    • {{val.Label}}: Display specific filter values, such as 'Residential.'
    • {{val.Link}}This is the intelligence of AnqiCMS!It will automatically generate a URL with the corresponding filter parameters.When the user clicks this link, the page will refresh with these parameters and display the filtered content.
    • {% if val.IsCurrent %}active{% endif %}: This is a very practical judgment, if the currentvalis the filter condition selected by the user,IsCurrentwill returntrue.You can use this to add to the selected filter conditionsactiveclass to highlight through CSS and enhance user experience

Combine document list with pagination function

archiveFiltersThe tag itself is only responsible for generating filter conditions, to make the filtering effective and display content, it needs to be配合archiveListandpaginationlabel usage

When the user clicks onarchiveFiltersAfter generating the filter link, the page URL will automatically contain similar?housetype=住宅&roomtype=两室两厅Such query parameters. At this point, yourarchiveListtags come into play. As long as yourarchiveListuptype="page"It will intelligently parse the filter parameters from the URL and query the corresponding documents from the database based on these parameters.

For example, you can use it in your list page template like this.archiveListandpagination:

{# 房产文档列表 #}
<ul class="property-list">
    {% archiveList archives with moduleId="2" type="page" limit="10" %}
        {% for item in archives %}
        <li>
            <a href="{{item.Link}}">
                <h4>{{item.Title}}</h4>
                <p>{{item.Description}}</p>
                {# 这里可以显示更多文档信息,比如自定义字段 #}
                <p>户型:{% archiveDetail with name="户型" id=item.Id %}</p>
            </a>
        </li>
        {% empty %}
        <li>
            抱歉,没有找到符合条件的房源。
        </li>
        {% endfor %}
    {% endarchiveList %}
</ul>

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

This code seamlessly connects with the filtering conditions, when filtering parameters are passed through the URL,archiveListit will automatically filter the data, andpaginationThe pagination link will be generated correctly based on the filtered results, ensuring that users can navigate normally after filtering.

Make the filtering feature more user-friendly.

In order to make your filter function more intuitive and easy to use, there are some details to pay attention to:

  1. Highlight the currently selected item:Utilizeval.IsCurrentAttribute, for the current user's selection

Related articles

How to display the custom parameter fields of AnqiCMS documents on the front page, such as authors, sources, and so on?

In website operation, the flexibility of the Content Management System (CMS) is crucial.AnQi CMS, with its powerful customizability, allows us to add various custom parameter fields to content (such as articles, products, etc.) to meet diverse display needs.These custom fields, such as the 'author', 'source', 'model', 'color' of products, etc., can greatly enrich the dimensions and practicality of content.How can we elegantly present these personalized custom parameters to visitors on the website frontend after we have added them in the background of the document

2025-11-09

How to display the AnqiCMS related document list on the front page to increase content relevance and user stay time?

In content operation, we all hope that users can stay longer on the website and browse more content.An精心 crafted article is indeed important, but how to connect it with other relevant content to form a content matrix is the key to improving user experience and reducing bounce rate.Imagine, after a user finishes reading an article about 'AnQi CMS Core Features', if the page below automatically recommends 'How to Build an E-commerce Site with AnQi CMS' or 'AnQi CMS Template Creation Tutorial', wouldn't it be more attractive for them to continue exploring?

2025-11-09

How to display the 'Previous' and 'Next' documents of the current document on the front page to enhance the user's browsing experience?

In AnQiCMS (AnQiCMS), adding "Previous" and "Next" navigation links to the front-end document pages is an important means to enhance user browsing experience and extend user stay time.When a user finishes reading an article, these links can guide them naturally to discover more related content, avoid interrupting page browsing, and effectively reduce the bounce rate, which also helps to enhance the overall weight of the website's content. AnQi CMS as a rich-featured Go language content management system, built-in with a powerful template tag system, allowing website operators to flexibly control content display. Among which

2025-11-09

How to accurately display the detailed content of a specific AnqiCMS document on the front page, including the title, description, and image?

AnQiCMS (AnQiCMS) leverages its flexible content model and intuitive template tag system, allowing you to easily manage the display of website front-end content.It is particularly important to understand the core mechanism and common tags when we need to present the detailed content of a specific document accurately on the front page, such as the title, description, full text, and related images.### Understanding the content structure of Anqi CMS In Anqi CMS, all content is organized based on the "content model", such as common article models, product models, etc.

2025-11-09

How to display the AnqiCMS document Tag list on the front page and support filtering by letter or category?

In a content management system, a tag (Tag) is a powerful tool that helps us organize content more flexibly and improve the efficiency of users in finding relevant information.AnQiCMS as an efficient enterprise-level content management system naturally also deeply integrates powerful tag features.If you are hoping to display a list of document tags on the website front end and allow users to filter by letter or category, this article will provide you with a comprehensive guide.

2025-11-09

How to display detailed information of a specific AnqiCMS Tag on the front page, such as description and Logo?

AnqiCMS as an efficient content management system not only provides rich content publishing and management functions, but also provides great flexibility for the display of front-end pages.In website operation, properly using tags (Tag) can effectively enhance the organization of content, user experience, and search engine optimization (SEO).When a user browses to a specific tag, if the page can directly display the detailed information of the tag, such as its description and exclusive Logo, it will undoubtedly greatly enhance the professionalism and attractiveness of the page.Next, we will explore how to use the AnqiCMS front page

2025-11-09

How to display the document list associated with a specific Tag of AnqiCMS on the front page?

In website content operation, effectively organizing and displaying related content is crucial for improving user experience and the SEO performance of the website.The AnqiCMS Tag (tag) feature is exactly for this purpose.By cleverly using Tag, we can not only provide users with more accurate content navigation, but also make search engines better understand the structure of the website content. This article will focus on how to clearly and effectively display the document list associated with a specific Tag in AnqiCMS on the front page of a website.###

2025-11-09

How to display the AnqiCMS comment list on the front page and support pagination and parent-child comment display?

AnQi CMS provides a convenient comment function for website content interaction, allowing visitors to express their opinions on articles, products, and other content.For website operators, how to clearly display these comments on the website front-end and provide user-friendly pagination and parent-child comments (i.e., reply function) is a key link to improving user experience.Below, let's discuss how to achieve this goal in AnQi CMS.

2025-11-09