Filter dynamic content items by URL

With the support of hierarchical dynamic modules, Sitefinity CMS provides the option to filter the dynamic content items by their parents. The following procedure describes how to filter dynamic content items by their parent via the URL.

Once you activate the dynamic module, a corresponding section is created in Sitefinity CMS toolbox with both Standard and MVC widgets reflecting the names of the content types.

EXAMPLE: For a module with name Travelling Agency, a section with name Travelling Agency is created. For Countries dynamic content type, two widgets are automatically added to the toolbox section - Countries and Countries MVC.

To filter the dynamic content items by their parents, perform the following:

  1. Create a new page with name Cities and drop the Cities MVC widget on the page. 
  2. Click Edit to open the widget designer.
  3. In the Content tab, select From currently open country radio button and click Save.
    As a result, the widget designer informs you that only Cities from the currently open Countries will be displayed:
    For more information, see Dynamic items selector.
  4. Save your changes, publish the page, and open it on the frontend.
    The page displays an empty list.
  5. To choose whether you want to display the whole list of items when no country is specified in the URL, in the widget designer, click Advanced » Model.
    In ShowListViewOnEmpyParentFilter, enter true or false. In this scenario, leave the default value, which is false.
  6. To filter the cities by country, add a name of a country to the URL.
    For example, http://domain:xxx/cities/bulgaria
    A list of all the cities in Bulgaria appears. If you click an item title, by default you are redirected to the Detail view of the item.
  7. To choose whether to open the Detail view when an item is clicked, in the widget designer, click Advanced » Model
    In ListMode, enter true or falseTrue means that the detailed mode will not be opened.
    In this scenario, leave the default value, which is false.

    NOTE: You can also display a list of dynamic content items and highlight the selected one. For more information, see Highlight filtered items.

Want to learn more?

Sign up for our free beginner training. Boost your credentials through advanced courses and certification.
Register for Sitefinity training and certification.

Was this article helpful?