Filter dynamic content items by URL

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

The following tutorial creates the relationship between Countries, Cities and Hotels. For more information about creating the module and its content types, see Create Travelling agency site with hierarchical types
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, 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 new page with name Cities and drop the Cities MVC widget on the page. 
  2. Click the Edit button 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 Country will be displayed:
    Cities Designer
    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. Tho 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 tutorial, leave the default value, which is false.
  6. To filter the cities by country, add a name of a country in 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 details view of the item.
  7. To choose whether to open the detail view whan an item is clicked, in the widget designer, click Advanced » Model
    In In ListMode, enter true or false. True means that the detailed mode will not be opened.
    In this tutorial, 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?