Filter expression for dynamic content in sitefinity

995 Views Asked by At

Using SF 9.1 feather. Have created two modules in the module builder. One is a related data field of other. Specifically products is the parent and promotions is the child. When I drop the product widget onto a page I like to specify a filter vs displaying all products. I can limit the products via the filter expression in advance mode of the model. I seem to be able to find examples of filters for simple properties say price. But how do I filter based on a property of its related data? Eg promotion expiration date.

Alternatively is there a way to pass a string as a parameter to the widget so I can filter the products in razor ?

3

There are 3 best solutions below

1
On BEST ANSWER

In this case I think it is better to create your own MVC controller. Inside of it you get the data using the Sitefinity API, sort by whatever you want and pass it to the view (which should be custom as well).

There is no easy way to pass a random string from the built-in widget to the built-in View. I've once used the CssClass property to pass a string, but as you can imagine it is not too safe and is prone to errors.

0
On

You could use the method described in the documentation, where you place both widgets on the same page and reference the parent type in the child type widget.

http://docs.sitefinity.com/feather-filter-dynamic-content-items-by-related-data

0
On

Assuming that the field you are using is a date time and also assuming that you want to "hide" expired items, could you not use the scheduling feature of Dynamic modules to publish and unpublish your times on particular dates.