This project is read-only.

Query Filtering by ListBox Values

Topics: General
May 23, 2012 at 5:58 PM

I have an Enumeration field attached to a custom content type of "Client". This enumeration is of type ListBox and I put in a bunch of string values that correspond to the product names (Title part) of the content types I want to map them to.

I placed a projection widget on these product pages with a query to retrieve clients associated with this content. My filter in the query is:

Content Type is "Client"


Client.Associated Products contains '{Content.DisplayText}'

For some reason this is not returning the clients that I map in the listbox for each product. Any thoughts on this? Does the contains work with ListBox? Any easier methods to achieve such a mapping?

May 23, 2012 at 6:48 PM
Edited May 23, 2012 at 7:09 PM

Based on some preliminary test, it looks like it is filtering on all the values in the enumeration list box and not the "selected" values as it indicates. I will investigate further.

I tried swapping out the different enumerations and it looks like they are not checking the selected values, but just the containing value. I changed the filter to "equals" instead of "contains" and that did not change it either.

May 23, 2012 at 7:16 PM

The issue as I understand your scenario is that {Content.DisplayText} might be empty. I am assuming you expect {Content} to be the currently displayed content item ? If yes then it's a bad assumption, because a page can display multiple content items.

One solution could be to provide a token in the alias module which would return the content item associated with the current url. This would make more sense, and work in your case. Something like {Aliased.DisplayText}.

You want to file a bug (aka feature request) for this one ?

May 23, 2012 at 7:18 PM

A solution in the meantime would be to change the template of Client and insert the values from the list.
Another technical solution would be to create a "Related Content" part, like David Hayden has done recently:

May 23, 2012 at 7:37 PM

I agree with you saying the DisplayText may be null, but I also hardcoded the value into the filter string box and it still evaluated to true. To me it seems like the piece of functionality that is broken is the comparing of the selected list item values to the string in the filter box or the token.

I can file a bug for this, but could you point me to maybe where this is located so I can fix it and then submit the patch as well?


I will also look at David Hayden's related content part as well. This may be what I need.



May 23, 2012 at 7:54 PM

If you can't filter on a hard coded text, yes, file a bug

May 24, 2012 at 12:41 PM

I have submitted it as issue 18706. I think it resides in Orchard.Projections/Providers/ContentFieldsFilter.cs. I am just unfamiliar with how this works to filter here. It looks like it is passing the "Value" property on the field to filter on. If that helps :)