Developer forum

Forum » Feature requests » @RequestIfNotEmpty for itempublisher filters

@RequestIfNotEmpty for itempublisher filters

Sten Hougaard
Reply

Hi,

When you add Item filters to itempublisher you may need sometimes to have more than one filter value, like:

Filter by "city", "country", "age".

You then want to use dynamic filters using @Request(city) for instance.

Since it is a style where you need all filters to be a hit, you set the filters to use AND. Here the problem occurs..:

Say the user first choose "city=aarhus", then it will turn into a filter:
"city=aarhus&country=&age="
To be a hit an item need to have city="aarhus", "country='empty'" and "age='empty'", which means that no items will be found (as normally each field have a value).

My request is: Add a new dynamic parameter something like:
@RequestIfNotEmpty(city)
It will then only use the filter if the parameter is NOT empty.


Med venlig hilsen/Best regards,

Sten Hougaard
Webudvikler

E: sho@1stweb.dk
M: 29850818
A: København/Aarhus . W: www.1stweb.dk
@: netsi1964


Replies

 
Mikkel Ricky
Reply

Hi Sten,

Your proposed solution for this will not work due to the way the item filters work and are implemented. But it surely makes sense to be able to dynamically filter the items published.

A way to do it is to let the item publisher automatically use a filter from the query string, i.e. if it publishes items with a field Name and the query string contains a Name parameter, Name=M, then only items with Name equal to M will be published. We can also use Name=*M to find items where Name ends with M, Name=*M* for Name containing M and Name=M* for Name ending with M. For non-string values we should be able to specify an operator as well, e.g. Number=10&Number.op=gt for items with Number > 10 (or maybe just Number=>10 (url encoded: Number=%3E10)?).

This is pretty easy to implement, but we need to discuss it in further details (both at HQ and in this forum) to find out exactly how it should work. Any comments and suggestions from you are very welcome.

Best regards,
Mikkel