How to use the `archiveList` tag to perform keyword search (using `q` parameter) to filter documents on the frontend page?

Calendar 👁️ 58

Unlock AnQiCMS: Use巧妙archiveListTags to implement keyword search and content filtering on the front-end page

As an experienced website operations expert, I am well aware of the importance of an efficient and flexible content management system for a company.AnQiCMS, this system developed based on the Go language is renowned for its excellent performance and rich features and is becoming the preferred choice for an increasing number of small and medium-sized enterprises and content operation teams.In this era of information explosion, whether users can quickly find the content they need is directly related to the user experience and conversion rate of the website.Today, let's delve deeply into a very practical and powerful feature of AnQiCMS - how to usearchiveListlabel'sqParameters, easily implement keyword search and content filtering on the front-end page.

UnderstandingarchiveListThe power and flexibility of tags

In the AnQiCMS template system,archiveListTags are undoubtedly the core tool for content display. It is like a universal content query machine, helping us to find documents based on various conditions, such as document model ID (moduleId), classification ID (categoryId), recommended attributes(flagList out the articles and products we need. Whether it's showcasing the latest news, popular articles, or product lists under specific categories,archiveListwe can accomplish the tasks with ease.

It not only supports flexible sorting methods (order) such as sorting by the latest release or views, but also can accurately control the number of displayed items (limit)。But its capabilities are far from limited. When we need to implement more advanced content interaction, such as allowing users to actively search for information within the site,qthe parameter shines on the scene, it willarchiveListFrom a static content display tool, upgraded to a powerful dynamic content filtering engine.

Core function:qParameter - the secret weapon of front-end keyword search.

In short,qThe parameter isarchiveListA parameter specifically used to receive keyword search requests. When you want the website to intelligently filter out a word entered by the user on the frontendThe title contains this wordwhen searching for the document,qThe parameter is your best choice. This means that the user only needs to enter the keywords they are interested in, and the system can quickly match and present a list of relevant content, greatly enhancing the discoverability of the content.

It is noteworthy that in order to fully utilize its search filtering and pagination display capabilities,qthe parameters are usually used withtype="page"this list type.type="page"TellarchiveListCurrently, it is a paginated list that intelligently cooperates with pagination tags (pagination) to work together, providing a complete pagination function for search results.

The intelligence of AnQiCMS lies in the fact that if the page URL already containsq=关键词query parameters,archiveListThe tag is intype="page"In mode, it will automatically recognize and use this keyword for filtering, without us needing to specify it within the tagqParameters. This design greatly facilitates developers, making the implementation of the search function more concise and efficient.

Practical training: Build the front-end keyword search function step by step.

Next, we will demonstrate how to implement a basic keyword search function in AnQiCMS with a simple example.

1. Create a search form

Firstly, we need to provide a user-friendly search entry on the front-end page, usually a HTML form.This form can be placed anywhere on the website, such as the navigation bar, sidebar, or a dedicated search page.

<form method="get" action="/search">
    <div class="search-box">
        <input type="text" name="q" placeholder="请输入搜索关键词" value="{{urlParams.q}}">
        <button type="submit">搜索</button>
    </div>
</form>

In this form:

  • method="get"It indicates that the form is submitted using the GET method, the search keywords will be attached to the query string of the URL (for example)/search?q=关键词)
  • action="/search"It specifies that the search results page will be/searchMake sure that the AnQiCMS template directory containssearch/index.htmlfile, or route the search request to the correct template through the backend pseudo-static rules.
  • name="q"This is a crucial point, it defines the name of the keyword input box, andarchiveListlabel'sqcorresponds to the parameters.
  • value="{{urlParams.q}}"This part is a little trick, it ensures that the search box still displays the keywords entered by the user after submitting the search, enhancing the user experience.

2. Display search results

Next, it is to configure the display page of search results. Suppose we have onesearch/index.htmltemplate is specifically used to display search results.

In this template, we will usearchiveListLabel to dynamically retrieve and render a list of documents that match the search criteria. See the following example code:

”`twig {# search/index.html template content example #}

{# Introduce the common header, usually containing the search form itself #} {% include “partial/header.html” %}

<h1>搜索结果</h1>

{# 使用 archiveList 标签获取搜索结果 #}
{% archiveList archives

Related articles

How to set the display quantity and offset for the `archiveList` tag in AnQiCMS to achieve pagination?

As an experienced website operations expert, I know that an efficient and flexible list display method is crucial for user experience and website performance.AnQiCMS (AnQiCMS) provides us with great convenience with its powerful template tag system.Today, let's delve into how to cleverly set the display quantity and offset using the AnQiCMS `archiveList` tag to achieve a smooth pagination effect.

2025-11-06

How to implement sorting of the document list by views or publication time using the `archiveList` tag?

As an experienced website operations expert, I know that the core value of a content management system (CMS) lies in its flexibility and the efficiency of content presentation.AnQiCMS (AnQiCMS) excels in this aspect with its efficient architecture in the Go language and a rich set of features.Today, let's delve deeply into a function that is extremely commonly used in content operation: how to use the `archiveList` tag to sort the document list by views or publication time.Content sorting seems simple, but it actually contains profound operational strategies.

2025-11-06

How to use the `archiveList` tag to get documents with specific recommended attributes (such as "Top Stories" or "Slideshow")?

As an experienced website operations expert, I am well aware of the core value of a content management system (CMS) in terms of its flexibility and content scheduling capabilities.AnQiCMS (AnQiCMS) boasts its efficient architecture based on the Go language and rich features, providing strong support for content operations.Today, let's delve into a very practical scenario in content operation: how to accurately obtain and display documents with specific recommendation attributes using the `archiveList` tag, such as the website's 'headlines' news or important content for the 'slideshow' carousel.

2025-11-06

How to exclude documents of a specific category in `archiveList` to display accurate content?

As an experienced website operations expert, I am well aware of the importance of accurate content display for user experience and website operation efficiency.In a content management system, we often encounter the need to exclude certain specific categories of documents when generating article lists, in order to ensure the relevance and focus of the content.AnQiCMS (AnQiCMS) is an efficient and flexible content management tool that provides us with a very convenient solution.

2025-11-06

How to retrieve related content of the current document using the `archiveList` tag's `type="related"` mode?

As an experienced website operations expert, I am very happy to delve deeply into the `archiveList` tag in AnQiCMS with the `type="related"` mode, which plays a crucial role in content operations and can effectively improve user experience and the website's SEO performance. --- ## In-depth Analysis of AnQiCMS's `archiveList` Tag: How to intelligently retrieve related content and enhance user experience In such an efficient and customizable content management system as AnQiCMS

2025-11-06

How to call the document data of different sites (`siteId`) through the `archiveList` tag?

As an experienced website operations expert, I fully understand the challenges you may encounter when managing multi-site content.AnQiCMS (AnQiCMS) provides us with great convenience with its powerful multi-site management capabilities.Today, let's delve into how to use the `archiveList` tag and its core parameter `siteId` to easily implement cross-site document data calls.

2025-11-06

How to get the thumbnail, description, and publish time of the document in the `archiveList` loop?

As an experienced website operations expert, I know that how to efficiently and flexibly display content in a content management system is one of the key factors for the success of a website.AnQiCMS (AnQi CMS) relies on its powerful template engine and simple tag design, making content display extremely convenient.Today, let's delve into a very practical scenario: how to elegantly obtain and display the thumbnail, description, and publication time of documents in the `archiveList` loop.

2025-11-06

How to display the Flag attribute of the document in the `archiveList` loop, for example, 'Recommended' or 'Bold'?

As an experienced website operations expert, I am happy to deeply analyze how to flexibly use the `archiveList` loop in AnQiCMS to display the Flag attribute of documents, such as "recommended" or "bold".The core of content operation lies in how to effectively distinguish and highlight key content, and the Flag attribute is a powerful and easy-to-use feature provided by AnQiCMS for this purpose.--- ### Light up your content

2025-11-06