Filter dynamic content items

When you have multiple dynamic content types, you can create various structures and offer filtering according to parent type on the frontend.

Direct parent filtering

EXAMPLE: Your have a dynamic module named Travelling Agency. Your hierarchy of dynamic types is Cities » Hotels. You want to filter hotels by city – when you click a City, all Hotels in this City are displayed.

Procedure

  1. Drop the Cities and the Hotels widgets on the page.
  2. Open the Hotels widget for editing.
  3. On Contents tab, select From the currently open country.
  4. This sets FilterByParentUrl property to true.
  5. Save your changes.

Filter by explicitly set parent

EXAMPLE: Your have a dynamic module named Travelling Agency. Your hierarchy of dynamic types is Countries » Cities » Hotels. You want to filter Hotels by Country. Country is nor a direct parent, but a grandparent of Hotels. When you click a Country, all Hotels in this country are displayed.

Procedure

  1. Drop the Countries and the Hotels widgets on the page.
  2. Open the Hotels widget for editing.
  3. On Contents tab, select From the currently open city.
  4. This sets FilterByParentUrl property to true.
  5. Click Advanced button.
  6. In FilterParentTypeName, enter the name of the parent type that you want to use for filtering.
    The type has the following format:

    Telerik.Sitefinity.DynamicTypes.Model.<DynamicModuleName>.<DynamicTypeName>

    In this case,

    Telerik.Sitefinity.DynamicTypes.Model.TravellingAgency.Country

    NOTE: The type that you want to use for filtering must be predecessor of the filtered type.

  7. Save your changes.

Multilevel filtering

EXAMPLE: Your have a dynamic module named Travelling Agency. Your hierarchy of dynamic types is Countries » Cities » Hotels. You want to filter Cities by Countries, Hotels by Country, and Hotels by Cities. When you click a Country, all Cities in this County are displayed and all Hotels in this country are displayed. When you click a City – the list of the Hotels in the Country are filtered by this City.

Procedure

  1. Drop the Countries, Cities, and Hotels widget on the page.
  2. Open the Cities widget for editing.
  3. On Contents tab, select From the currently open country.
  4. Save you changes.
  5. Open the Hotels widget for editing.
  6. On Contents tab, select From the currently open city.
  7. Click Advanced button.
  8. In FilterParentTypeName, enter the name of the parent type that you want to use for filtering.
    The type has the following format:
    Telerik.Sitefinity.DynamicTypes.Model.<DynamicModuleName>.<DynamicTypeName>
    In this case,
    Telerik.Sitefinity.DynamicTypes.Model.TravellingAgency.Country
  9. In EnableParentMultipleLevelFiltering, enter true.
  10. Save your changes.

Configure parent types to behave as filters

When you apply filtering in hierarchical structures, you can configure the content types to behave as filters, rather than as regular lists and details views. For example, not to open the detailed view when a parent item is clicked and also to highlight the currently selected item.

  • To set the child type widget to display a list of item before any filter is applied, open its widget for editing and in the Advanced settings, in ShowListViewOnEmpyParentFilter, enter true.
    This way, the widget will not display an empty list, if no parent item has been selected.
  • To set the parent type widget to display items in list mode only, open its Advanced settings and in ContentViewDisplayMode, enter Master.
    This way, when you use a content type, only as filter, when you click an item in the list, it will not open in Details mode.
  • To mark the currently selected item, open the Advanced settings of the widget and in SelectCurrentItem, enter true.
    This way, when you use a content type, only as filter, when you click an item in the list, it will be selected.
    To modify display for the selected item, you can edit the SelectedItemTemplate of the widget, in the following way:

Display parent item in child items List View

EXAMPLE: Your hierarchy of dynamic types is Cities » Hotels. When you display the list of Hotels in the city of London, you want to add a heading before the list - Listed hotels are in London city.

If you want to display information about the parent item in the list view of a child type, you can add the following template to the list template of child items. You need to add

The DynamicContentViewMaster checks, if a DynamicDetailContainer with id parentDetailContainer exists, and binds the container, if one is found. 

Was this article helpful?