How to filter news articles using date range kentico
In Kentico, you can filter news articles using a date range by creating a custom query or using the built-in filtering options. Here are a steps to achieve this:
Method 1: Using the built-in filtering options
- Go to the News module in your Kentico instance.
- Click on the "Filter" button at the top of the page.
- In the "Filter" dialog box, click on the "Date" tab.
- Select "Date range" as the filter type.
- Choose the "Published date" or "Modified date" field as the date field to filter on.
- Enter the start and end dates for the date range you want to filter by.
- Click "Apply" to apply the filter.
Method 2: Using a custom query
- Go to the News module in your Kentico instance.
- Click on the "Query" button at the top of the page.
- In the "Query" dialog box, click on the "Add condition" button.
- Select "Date" as the condition type.
- Choose the "Published date" or "Modified date" field as the date field to filter on.
- Select "Between" as the operator.
- Enter the start and end dates for the date range you want to filter by.
- Click "Apply" to apply the query.
Method 3: Using a macro
- Go to the News module in your Kentico instance.
- Click on the "Query" button at the top of the page.
- In the "Query" dialog box, click on the "Add condition" button.
- Select "Macro" as the condition type.
- Enter the following macro code:
{{ NewsItem.PublishedDate >= '{0}' && NewsItem.PublishedDate <= '{1}' }}
- Replace
{0}
and{1}
with the start and end dates for the date range you want to filter by. - Click "Apply" to apply the query.
Method 4: Using a custom web part
- Create a new web part in your Kentico instance.
- In the web part, add a "News" data source.
- In the data source, add a "Filter" property and set it to "Published date" or "Modified date".
- In the filter property, enter the start and end dates for the date range you want to filter by.
- Add the web part to your page and configure it as needed.
These are the different ways you can filter news articles using a date range in Kentico. The method you choose will depend on your specific requirements and the complexity of your filtering needs.