In the daily operation of websites, providing users with an efficient and convenient in-site search function is a key element in improving user experience and guiding content discovery.For those of us using AnQiCMS to manage website content, achieving this feature is not a difficult task.qLet us be able to easily search for keywords in the document list.
Start the journey of in-site search: UnderstandingqParameters
At the document list interface of Anqi CMS,/api/archive/list),qParameters play a core role.It allows us to specify a search keyword, thereby filtering out all documents that contain the keyword in the title.Imagine that when users are looking for specific information on your website, they only need to enter a few words in the search box to quickly find the relevant content, which will undoubtedly greatly enhance their satisfaction with the website.
To makeqThe parameter takes effect, and there is an important prerequisite, that is the type of the document list must be set totype) must be set topage). Whentype="page"When this is the case, Safe CMS will return a document list with pagination information, and at this timeqParameters must be parsed correctly to execute keyword search. This means that if you want to build a complete in-site search page, display search results, and support pagination browsing, then you willtypesetpageIt is indispensable.
Actual operation: How to use in URLqParameters to search
Utilize in practical applications,qParameters search is very intuitive. When the user enters a keyword into the search box on the website's front end and submits it, your website (or front-end application) will use this keyword asqThe value of the parameter, added to the/api/archive/listrequest URL of the interface.
For example, if your website domain isyourdomain.com,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 backend of AnQi CMS will identify your search intent and return a list of documents that contain "AnQi CMS tutorial" in the titles, along with pagination information.
Optimize search experience: Combine other parameters
qAlthough powerful, it usually needs to work with other parameters to provide more accurate and user-friendly search experience.
- Specify content model (
moduleId):Your website may contain various content models such as articles, products, cases, etc. If users only want to search for specific types of content, you can combinemoduleIdThe parameter is used to limit the search range. For example, to search for “Anqi CMS tutorial” limited to the article model, the request can be: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 time,categoryIdthe parameter comes into play, making the search results more focused. - Pagination (
page,limit)To avoid loading too much data at once, and also to facilitate users in browsing a large number of search results,page(current page number) andlimitThe 'auto' parameter is required.When the user clicks the 'Next' or 'Previous' page on the search results page, these parameters will be updated accordingly to retrieve the correct search result fragment.
Through flexible combination of these parameters, you can provide users with highly customized on-site search functionality, enabling them to quickly locate the target content whether they are looking for a product, a tutorial, or a news article.
The value of in-site search for content operation
The in-site search function is not just about technical implementation; it has profound significance for content operation. An efficient in-site search can:
- Enhance user satisfaction:Quickly find the information they need, users are more likely to stay longer on your website and become loyal customers.
- Optimize content strategyThrough analyzing users' search keywords, you can gain insights into their interests and needs.What words are frequently searched?Which search terms did not find a suitable result?This data can provide valuable reference for the direction of your content creation.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 in a specific category or topic through search, this may suggest that you can highlight these parts more in the website navigation and optimize the overall information architecture.
In short, the Anqi CMS isqParameters provide the convenience for us to build a powerful and flexible on-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.
Common Questions (FAQ)
Q1:q参数只能搜索文档标题吗?A1: 根据文档描述,qThe parameter is mainly used to search for documents that contain the specified keywords in the title.If you need to perform more advanced searches on the document text or other fields, you may need 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 toq参数?A2: Normally, 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 take the keyword asqThe value of the parameter, added to the URL through the GET request method. Or, you can also use JavaScript to capture user input and dynamically construct a URL containingqThe API request URL for parameters, loaded by AJAX or redirection to display search results.
Q3: If I don't want the search results to be paginated,q参数还会生效吗?A3: 不会。文档明确指出,q参数仅在列表类型type="page"时生效。如果您将typesetlist(默认值),qThe parameter will not take effect, you will not be able to filter the results by keywords. Therefore, in order to implement in-site search, it is essential totypesetpage.