Ektron Reference |
XMLSearch Server Controls display a Smart Form's fields on a search page. A site visitor can use the fields to search for Smart Form content.
To provide search capabilities to your Web site content, insert all three controls onto an .aspx template. Because the search functions are managed by separate controls, you can place a search field and button in a one section of a page, and the results in another.
Also, unless you want to use the default paging properties (which show only ten results), insert an EktronUI Pager control on the page to manage the paging of the search results.
Prerequisite: Search server controls were added to the Visual Studio Toolbox. See Adding Search Server Controls into Visual Studio.
If you drag and drop controls from the VS Toolbox, the necessary register
statements are automatically added to the page. If you copy and paste the sample code, add the following register
statement for templated controls:
<%@ Register assembly="Ektron.Cms.Framework.UI.Controls" namespace="Ektron.Cms.Framework.UI.Controls" tagprefix="ektron" %>
For Ektron UI controls, use this register
statement:
<%@ Register assembly="Ektron.Cms.Framework.UI.Controls.EktronUI" namespace="Ektron.Cms.Framework.UI.Controls.EktronUI" tagprefix="ektronUI" %>
The tag prefix can be anything as long as it matches the control's prefix.
Here is a basic template showing the three controls.
The XmlSearchInputView Server Control displays a Smart Form's fields and lets users search on them.
IMPORTANT: Only fields marked Indexed appear on the form. Also, you cannot search a Smart Form field if its entire xpath exceeds 64 characters. See Also: Specifying Which XML Elements are Indexed
Because XML fields have a type (for example, string, date, choice, integer, boolean), the template is dynamic and connected to a Smart Form’s data structure.
The SearchModel gets bound to (that is, determines) the view. When viewing the SearchModel in the object browser, you see a property named “fields”, which is a list of each XML Smart Form field.
To view the searchmodel for XML Smart Forms, insert XMLField into the Object Browser. The class consists of a
Label - friendly name
Name - internal smart form name
Xpath - path to field in Smart Form
XML Smart Form search controls use these fields to retrieve and display Smart Form content.
As explained in Using Data Field Types, there are many types of Smart Form fields. Each type has a subclass, which has a corresponding user control, an .ascx template file. User controls are located in C:\Program Files(x86)\Ektron\CMS400vversion\workarea\FrameworkUI\Templates\Search\Fields. As explained in Modifying the Default Markup, to change a control's default markup, modify its template.
Smart Form field controls receive an XML field and cast it into the specified field type. For example, the Object Browser shows that the ChoiceField template (ChoiceField.ascx) contains a
List of possible choices
Selected value - the current selection
SelectionMode – select one or many?
The ChoiceField template receives an XML field and casts it into a choice field.
Prerequisite: An understanding of the structure of XML field types, as explained in The Search Model for XML Smart Forms .
Follow these steps to create an XML Smart Form Search template.
<ektron:XmlSearchInputView ID=”xmlSearchView” runat=”server” ControllerID=”SearchController” XMLConfigId=”10”>
<ItemTemplate>
<asp:ListView ID=”fields” DataSource=’<%# Eval(“Fields”) %>’ runat=”server”>
NOTE: The DataSource is the field's array returned from the SearchModel.
<ektron:XmlSearchInputView ID=”xmlSearchView” runat=”server” ControllerID=”SearchController” XMLConfigId=”10”>
<ItemTemplate>
<asp:ListView ID=”fields” DataSource=’<%# Eval(“Fields”) %>’ runat=”server”>
<ItemTemplate>
<ItemTemplate>
<ektron:XmlSearchInputView ID=”xmlSearchView” runat=”server” ControllerID=”SearchController” XMLConfigId=”10”>
<ItemTemplate>
<asp:ListView ID=”fields” DataSource=’<%# Eval(“Fields”) %>’ runat=”server”>
<ItemTemplate>
<ektron:XmlSearchField ID="uxField" runat="server" Field='<%# Container.DataItem %>'></ektron:XmlSearchField>
<ItemTemplate>
The XMLSearchField control lets you manage the display of XML Smart Form fields displayed in the ListView. So, you can modify the search input form with effects like the <ItemSeparatorTemplate>, which lets you place text, images, etc., between each field.
You can customize the behavior of an XML Smart Form field on the input form.
This is a complex procedure because, when a user clicks the Search button, your template must retrieve the modified fields, pass that data to the containing template which, in turn, passes the modified fields to the Search API. Use two-way data binding to perform this procedure.
The following steps provide an example of how to customize an XML Smart Form field.
Prerequisite: You followed the steps in Creating your own XML Search Template.
<TextTemplate><asp:TextBox ID="aspValue" Text='<%# Bind("Value") %>' runat="server" </asp:TextBox></TextTemplate>
Notice that this example uses Bind, which is a two-way statement. If the user changes the value in the text box, then posts back, the Bind command pushes the data into the template. The child template then takes the modified data from the template and pushes it back to the data object.
Ektron Version 8.5, Doc. Rev. 2.0 (Dec. 2011)
Visit the Ektron Dev Center at http://dev.ektron.com 1–866–4–EKTRON
Ektron Documentation, © 2011 Ektron, Inc.