Facets

Smartsite 7.7 - ...

The facets element can be used to specify one or more facets.

XML CopyCode image Copy Code
<facets>  
  <facet title="DELETED_BY">
   <name>deletedby</name>
   <selectfield>UserId</selectfield>
   <query>
    select top 10 u.Nr, u.FullName, count(u.Nr) as cnt
    from (%mastersql%) x
    join AllUsers u on x.UserId = u.Nr
    group by u.Nr, u.FullName
    order by cnt desc
   </query>
  </facet>
  <facet typename="Smartsite.Manager.ContentTypeFacet" />
</facets>

Definition

A facet defintion is constructed by adding a facet element to the facets element of the Libray Configuration xml.

The definition should contain the following elements:

Element Description
title (attribute) The title of the facet, which is displayed within the library. Usually a localization string. 
name The name of the facet. Must be unique within the libray.
code (optional) The code of the facet. Defaults to the title (not localized).
selectfield The fieldname which should be included within the master sql query as selected field, which is the field on which the facet acts.
query The query to construct the facet.

The query should return three columns:

  • The primary key
  • The display name
  • The count

To (re)use an existing facet, which is implemented as C# component, just specify it's typename (fully qualified, including the assembly name when it's not included within the Smartsite.Manager assembly) using the typename attribute.

Collapsed

As of Smartsite 7.8, the facets within the libraries are displayed either expanded or collapsed.

To display a facet in the collapsed state, add the attribute collapsed to the facet element and set it's value to true.

Top x

As of Smartsite 7.8, facets are no longer limited to showing a top 10. Facets can be configured to be expandable.

When a facet has been configured to be expandable, initially the top 10 results will be shown. However, below this top 10, a More link will be shown which can be clicked to expand the result with 10 more results at a time.

To configure a facet to be expandable, add the expandable attribute to the facet element and set it's value to true.
Furthermore, you should add the "top %numberofrows%" clause to the facet query.

To be able to determine when the More link should be hidden because there are no more results, you should specify the maxrowsquery element, see the example below.

XML CopyCode image Copy Code
<facet title="LASTEDITEDBY" expandable="true">
 <name>lasteditedby</name>
 <selectfield>UserId</selectfield>
 <query>
  select top %numberofrows% u.Nr, u.FullName, count(u.Nr) as cnt
  from (%mastersql%) x
  join AllUsers u on x.UserId = u.Nr
  group by u.Nr, u.FullName
  order by cnt desc
 </query>
 <maxrowsquery>
  select count(*) from (
   select distinct u.Nr
   from vwContent c
   join AllUsers u on c.UserId = u.Nr
   where c.AIMState != 2
  ) x
 </maxrowsquery>
</facet>