Configure Search results widget
Learn how to configure the Search results widget, a smaller brother of the list view, fitted in a widget, enhanced with additional UI features, and based on an XSLT query transformation.
Context
The widget can be placed anywhere and in any context (workspace page, asset page, etc.).
Prerequisites
You need to be familiar with XML and XSLT transformations.
Introduction
This widget displays search results from an XSLT query.
The widget appears as a list view that can be sorted and where you can perform a quick free text search to narrow down results. You can also switch between different list views – list, gallery, card, table – or open search results in a new search.
In addition to that, the results are paginated.
How to add this widget
Open the asset or workspace page you want to add the widget
Select the tab
In the page actions menu (three-dot menu on the top right), select Add widget type
Select Search results widget
Configuration
The widget is shipped with a standard asset-based censhare workspace and does not require any XML configuration. Everything can be done through the UI.
In the top right corner, click on the three-dot menu
Select Configure widget
Generic configuration
Please refer to the Generic configuration table in the Generic widget configuration tutorial.
Custom search configuration
Pagination
Depending on the size and position of your widget, you may need to configure the number of items per page to help users avoid scrolling.
Search transformation
You can use any existing transformation you have access to. You can also create your own following the instructions from this chapter: XML and XSLT . A new transformation needs to be created as an asset of transformation type.
Connect search results widget to a table widget
Needs to be done in the Search results widget and in the table widget.
The Search results widget can listen to a table widget placed on the same page. When widgets are connected, and the user selects an asset in the table widget, the Search results widget queries only the assets that correspond to the selection in the left widget, and displays only them. If the Search results widget is not connected to any table widget, it will show all query results.
This binding is therefore optional and is managed by the tickbox “Use asset selection from Table widget” and the Widget service id field. The Widget service id field only appears if you enabled the “Use asset selection from Table widget” tickbox. Please keep in mind that you first need to create the Widget service id in the workspace widget configuration of the table widget. For this:
open the workspace widget configuration asset that you created based on a table asset
go to the Details tab
find Widget properties
click on edit
scroll to the Internal workspace configuration
enter the XML configuration, including the
widgetServiceId
widgetServiceId
is the only new parameterall parameters are explained in this article – Configure Table widgets, under Workspace XML configuration; but you can set it following the instructions above
widgetServiceId
refers to a service that is used to broadcast messages from the table widget. Each widget that wants to consume those messages (e.g., when a user clicks on an asset) should specify such a key to be used.
Below you can find an example of such configuration which is shipped as part of the Media categories (structured search for image assets) workspace page.
<?xml version="1.0" encoding="UTF-8"?>
<xmldata>
<configuration widgetServiceId="mediaSearchCategories" sortable="true" tableId="censhare:table.structure.default.asset" toolbarTransformationKey="censhare:toolbar.categories-table-structure" rootQueryId="censhare:search.media.search.categories" childQueryId="censhare:search.media-search-categories-child-assets">
<relationConfigurations value="censhare:configuration.asset-relation.user.category-hierarchy.category.category."/>
</configuration>
</xmldata>
Using multiple widgets on the same page
You can have any number of table and Search results widgets on the same page; just keep in mind to connect them correctly. One table widget can “steer” more than one Search results widget, but the Search results widget can only listen to one table widget at once; otherwise, it shows no data.