In the daily operation of websites, providing users with efficient and convenient in-site search functions is a key link to improving user experience and guiding content discovery.For those of us using AnQiCMS to manage website content, it is not difficult to achieve this function.AnQi CMS provides a very practical parameter -qLet us be able to easily search for keywords in the document list.
Start the journey of on-site search: UnderstandingqParameter
At the document list interface of Anqi CMS (/api/archive/list),qThe parameter plays a core role. It allows us to specify a search keyword to filter out all documents with the title containing that keyword.Imagine, when users are looking for specific information on your website, they only need to enter a few words in the search box and can quickly find related content, which will undoubtedly greatly enhance their satisfaction with the website.
To makeqThe parameter is effective, there is an important prerequisite, that is the type of the document list (type) must be set topage. Whentype="page"At this time, Anqi CMS will return a document list with pagination information, and at this timeqParameters can be parsed correctly to perform keyword searches. This means that if you want to build a complete on-site search page, display search results, and support pagination, then you willtypeis set topageIt is indispensable.
Actual operation: How to use in URLqSearch by parameters
Utilize in practical applications,qThe parameter search is very intuitive. When the user enters a keyword in the search box on the front end of the website and submits it, your website (or front-end application) will use this keyword asqThe value of the parameter, add to the/api/archive/listinterface request URL.
For example, if your website domain isyourdomain.comIf the user searches for "AnQi CMS tutorial", then the API request URL may look like this:
yourdomain.com/api/archive/list?type=page&q=安企CMS教程
Through this simple URL structure, the AnQi CMS backend will identify your search intent and return a list of documents with titles containing "AnQi CMS tutorial", along with pagination information.
Optimize search experience: combine with other parameters
qThe parameter is powerful, but it usually needs to work with other parameters to provide a more accurate and friendly search experience.
- Specify the content model (
moduleId):Your website may contain various content models such as articles, products, cases, etc. If the user wants to search for specific types of content, you can combinemoduleIdParameters to limit the search range. For example, searching for "AnQi CMS tutorial" will limit the search to the article model, the request can be changed to:yourdomain.com/api/archive/list?type=page&moduleId=1&q=安企CMS教程 - Limit category (
categoryId)If the website content structure is complex, users may want to search within specific categories. At this point,categoryIdthe parameter can come into play, making the search results more focused. - pagination (
page,limit)To avoid loading too much data at once, and to facilitate users in browsing a large number of search results,pageand the current page numberlimit(The number of items displayed per page is a required parameter. When the user clicks on the 'Next page' or 'Previous page' on the search results page, the values of these parameters are updated accordingly to retrieve the correct search results segment.)
By flexibly combining these parameters, you can provide users with a highly customized in-site search function, allowing them to quickly locate the target content whether they are looking for a product, a tutorial, or a news item.
The value of in-site search for content operation
The in-site search function is not just about technical implementation, it has a profound significance for content operation. An efficient in-site search can:
- Improve user satisfactionUsers who can quickly find the information they need are more likely to stay longer on your website and become loyal users.
- Optimize content strategy: By analyzing users' search keywords, you can gain insights into their interests and needs.Which words are frequently searched? Which search terms did not find suitable results?This data can provide valuable reference for your content creation direction.You can create new content based on popular search terms, or optimize the title and description of existing content to make it easier to find.
- Improve website navigationIf a large number of users find content for a specific category or topic through search, this may suggest that you can highlight these parts more in the website navigation, optimizing the overall information architecture.
In short, the Anqi CMS'sqThe parameter provides convenience for building a powerful and flexible in-site search function.Master its usage and combine it with other parameters for optimization, which will significantly improve the user experience and content operation efficiency of the website.
Frequently Asked Questions (FAQ)
Q1:qCan the parameter only search the document title?A1: Based on the document description,qThe parameter is mainly used to search for document titles containing specified keywords.If you need to perform a more advanced search on the document text or other fields, it may be necessary to combine secondary development of AnQi CMS or consider integrating third-party search solutions.
Q2: How to get the user input keywords on the front-end page and pass them toqthe parameter?A2: Usually, you can set up a search form on the front-end page (<form>label), when the user enters a keyword and clicks the submit button, the form will automatically use the keyword asqThe value of the parameter, added to the URL via GET request. Alternatively, you can use JavaScript to capture user input and dynamically construct a URL that includesqThe API request URL of the parameter, then load the search results through AJAX or redirection.
Q3: If I don't want the search results to be paginated,qWill the parameter still take effect?A3: No. The document clearly states,qThe parameter only takes effecttype="page"when it is in the list type. If you settypeis set tolist(default value),qThe parameter will not take effect, you will not be able to filter results by keywords. Therefore, in order to implement in-site search, you musttypeis set topage.