Search:  

Creating a search results page with both page-based and form-based results

The Search Component provides the ability to search the text in the body of pages and sections, but, for good reasons, it does not allow you to search the text in embedded queries.

You can, separately, search a Query using a Search View. This enables you to specify which fields should be searched, and allows you to specify the view used to list out the results.

However for most users there is no visual distinction between pages which are created with text in the body, searchable using the Search Component, and pages whose content is rendered by embedded Queries. To provide an intuitive search experience for them it is necessary to query both systems at the same time and integrate the two results sets on the same page. This page describes how to configure that.

 

First prepare your site, with both the page-based and the form-based content.

Then, add in a Search Component. By default, this will allow you to search the page-based content.

Now you need to set up the searching of the Queries. As an example we'll assume you have a set of products, and you have two Queries, one which displays a list of products "Q: Products" and another, which shows this individual products "Q: Product".

Because we want to be as efficient as possible, we will re-use the "Q: Products" query, but that isn't essential.

Ensure the "Q: Products" query has all the fields that need to be searched included on it. This will typically include all the detailed description fields. (They probably aren't already included in this query, as you won't be displaying them all in the product listing array). However by adding them in to this Query you don't need to make them display, so don't worry about affecting the visuals.

Now add a Search View component, "SV: Products" and place this in your hidden admin area. Configure the Search View to use the "Q: Products" query and select all the fields to be searched (hold down ctrl / shift to multiple select as normal).

Back on the Search Component, click on Search Results in the toolbox, and you get a text editor for defining the layout of the search results. By default, this contains a single embed tag which shows the page-based search results.

For the greatest control over the layout, you can delete this embed tag and replace it with others (results set, header, etc)

You can now add in the embed tag which will display the search results from the Query. So embed "Q: Products", and choose the view which is used to display the array of products (for example, the Custom View). Then select the Search View from dropdown in the Search area of the embed. OK out to save the embed, and save the Search Results text as a whole.

Now we have the Query on the search results, we need to link the search field that the user enters their search on to trigger this Query as well as the page-based search results.

To do this, in the search Component, BE, Settings, Options, Search, check the box against the Query name listed in the 'Target Query Instances' control.

We need to do this both for the Search page itself, and, if we have a Search Box Component being used against the Search, you need to make the same setting in its BE, Settings.

This should now give you a fully functional integrated search, however you will probably want to tidy up the display of the results some more. There are useful options both in the Search Component, and in the Query that is embedded (BE, Settings, Options, Searches).

This example used only one Query, but you can embed several. (for example, you could use another in a separate column to give relevant 'adverts' being served from a different Form)


 

Copyright © 2023 Enstar LLC    All rights reserved Print this pageTranslate: