[opencms-dev] How to filter structured contents

Antonio Cordeddu antoniocordeddu at coranto.it
Fri Dec 28 17:17:26 CET 2012


Hi

You can find my opinions and suggestions point by point.

On 21/12/2012 19.27, gnorrus at libero.it wrote:
> Hi
>
> I have a form that display some events, ordered by event date
>
> I need to add two <select> to this form, that should filter those events by
> two values, that are:
> - Region of the event
> - Type of the event
>
> Which is the best way to do that?
>
> A search index or a contentload that filter categories?
I think it depends on how many content you have to search in. If you 
have a great number of resources I think a search index should be more 
suitable.

>
> If I use search index, how can I order the result events by event date desc?

You can use the setSort method, like in the following example:

Sort thisSort = new Sort();
// false = normal order (asc), true = inverse order (desc)
thisSort.setSort(new SortField("YourSorterField", SortField.STRING, true));
search.setSortOrder(thisSort);

>
> If I use contentload, can I filter by these two fields?

If you use OpenCms categories you can use the collector 
allKeyValuePairFiltered or timeFrameAndCategories (you can find a 
complete list of collectors on 
http://www.opencms-wiki.org/wiki/The_OpenCms_8_Demo_Template_Modules_in_Detail).

If you don't use categories you can loop the contents and make a test by 
comparing the input value form with the value of resource content.

Best regards

Antonio


_______________________________________
Coranto informatica di Antonio Cordeddu
Via Torricelli, 9 09047 Selargius (CA)
Phone:  +39 070 8607521
antoniocordeddu at coranto.it
Skype: antonio.cordeddu
http://www.coranto.it
___________________________________________





More information about the opencms-dev mailing list