Customizing facet view on a web site

Each facet has a number of parameters that can be customized. You can apply different facet rules while customizing the view of a facet on an NXT web site. Default rules for facet names are set in the publish.sdf file. When mounting the collection, you must observe the rule that if two or more collections contain the facets with the same names, these facets are considered as one facet. The request for the documents that refer to that facet category returns the documents from all collections. Facets from several collections that have the same root are merged to one tree.

Customizing facets with Content Network Manager

To tune facet titles on a web site in the Content Network Manager, complete the following steps:

  1. Open the Content Network Manager
  2. Right-click the node of a web site and select Site Properties from the menu.
  3. Select the Facets tab.
  4. Click Edit... to open the Edit Facet dialog and enter the facet parameters.

The list of facets on the Facets tab is an auto-collected list from all infobases that are mounted. Figure 1 shows the list of facets for the Olympic Medalists content collection.

Figure 1. List of facets for Olympic Medalists demo content collection

Each facet has the following facet parameters that can be customized:

Generating readable facet categories

NXT uses a string transformation engine to convert facet category titles to readable form. The transformation rules are stored in the Site Definition File (SDF). The following rules are default for SDF:

For example, the transformation result of the facet category title location/puerto_rico is Puerto Rico.

In many cases this transformation behavior is acceptable, but not always. An example of this is discussed here.

To change the titles of the facet categories created by default rules, complete the following steps:

  1. Open the Content Network Manager.
  2. Right-click the node of a web site and select Site Properties from the menu.
  3. Select the Facets tab.
  4. Click Title Rules... to open the Edit Title Rules dialog and enter the transformation rules.

Note: The Edit Title Rules dialog has the functionality of rule testing.

Figure 2 shows the Title Rules... dialog and functionality of rule testing.

Figure 2. Title Rules dialog and functionality of rule testing

For example, to change the name of the facet category in birth_date facet, apply the following rules:


<rule match="birth_date/(.*)$" replace="%1%">
	<rule match="(\d\d)/(\d)/(\d)" replace="%1%%2%%3%" stop="yes"/>
	<rule match="(\d\d)/(\d)" replace="%1%%2%0s" stop="yes"/>
	<rule match="\d\d">
		<rule match="18" replace="19 century" stop="yes"/>
		<rule match="19" replace="20 century" stop="yes"/>
		<rule match="20" replace="21 century" stop="yes"/>
	</rule>
</rule>
		

Different rules are applied to different hierarchy levels. Figure 3 shows the view of the Date of birth after applying the previous rules.

   

Figure 3. The view of the Date of birth facet

With the help of rules, it is possible to make different useful conversions. For example, with the rules, you can convert names of the US states written in the two-letter abbreviation into the full names.

Generating facets for non-Latin characters

You can use NXT facet rules to process non-Latin special characters, such as ä, Ä, ö, Ö, ü, Ü, ß, ç, and other special characters.

The default implementation of title rules includes the rule that converts the first letter of each word to the uppercase. The rule uses the \b regular expression for the upper-case conversion. A number of non-Latin characters are defined as a word boundary by this regular expression, and the next character after them is converted to the uppercase.

To process umlauts and other non-Latin characters correctly, you need to change the regular expression in the default title rules. Instead of <rule find="\b(\w)" replace="%1u%"/> , use the following two rules: <rule find="(?:^(\w))" replace="%1u%"/> and <rule find="(?:\s(\w))" replace=" %1u%"/>.

For example, you want to apply facet rules to the following words: Ðorđe Ðurić, Øystein Pettersen, Fußgängerübergänge. Figure 4 shows the view of the facet in the Output window with default title rules.

Figure 4. The view of the facet in the Output window

If we implement rules for non-Latin characters, the view of the facet will change. Figure 5 shows the view of the facet after implementation of the regular expression for non-Latin characters.

Figure 5. The view of the facet after implementation of the regular expression