Smart search filter by month

Vuthy Sok asked on June 14, 2018 12:00

Hello guys,

I have create Event Page Type then I want to filter start date by click dropdown list month.

January
February
....
December

I have spend many date search how to configure smart search filter but i can't find any answer how to do it. I have try code below is working yyyymmdd only one date.

+StartDate;20180613;Year

But I want to filter all posts in month that i choose from dropdown list.

Could you help me how to resolve this problem?

Thanks

Recent Answers


Rui Wang answered on June 14, 2018 15:50 (last edited on December 10, 2019 02:31)

Have you tried something like this

+StartDate;[20180301000000 TO 20180331000000];March
+StartDate;[20180201000000 TO 20180228000000];February

The example is in https://docs.kentico.com/k10/configuring-kentico/setting-up-search-on-your-website/using-search-filters#Usingsearchfilters-Conditionalfilters

Examples:

;;All
+classname;cms.smartphone;Smartphones
+_created;[{%ToSearchDateTime(CurrentDateTime.AddDays(-7))|(identity)GlobalAdministrator%}];Past week
+_content;product;Results related to products
+(documenttags{0} OR _content{0});product;Results related to products
-(issecurednode:(true) OR requiresssl:((int)1));;Exclude secured pages

But your design requires you to update the filter list every month as you move forward in a year. You could consider either create folder for 12 month, or add a drop down field to select month. Then the filter would not be based on actual year, but just the month.

2 votesVote for this answer Mark as a Correct answer

Vuthy Sok answered on June 15, 2018 03:28

Thanks Rui Wang for reply

Sorry i am no clear what you said "You could consider either create folder for 12 month, or add a drop down field to select month. Then the filter would not be based on actual year, but just the month."

Could you explain more details?

Thanks

0 votesVote for this answer Mark as a Correct answer

Rui Wang answered on June 15, 2018 03:38

Create folder like the following and store events in them. Then you filter will basically pull events from each sub folder.

Events
-- Jan
-- Feb
-- Mar

Or your Event page type, add a EventMonth field as a drop down where editor can select Jan, Feb, Mar. Then index EventMonth field as searchable. Then you filter for search would be

+EventMonth;Jan;January
+EventMonth;Feb;February
+EventMonth;Mar;March
1 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.