Virtual Happy Hour this month, Jun 28, we'll be getting a sneak preview at our soon to launch SaaS CMS!

Try our conversational search powered by Generative AI!

Is it possible to filter news topics in Alloy site with month and year?



I am using CMS 11 with .NET Framework 4.6 and I am trying to implement a filter for news articles for news and events list to filter them based on the month or year of publish.

Has anyone attempted it or does anyone has any reference to how it can be done? Please let me know,

I am also trying to add pagination to the list. If anyone has any references, please let me know.

Edited, Mar 06, 2022 15:53
Ted - Mar 06, 2022 20:13
With risk of sounding like we're on Stackoverflow: what have you tried so far? :)
Anant - Mar 09, 2022 18:32
I have tried JavaScript to implement pagination on the NewsPage list.
I couldn't find any option within EPIServer as all the current documentation refers to CMS 12 not 11.

Are you in the DXP? If so this should all be done using Search & Navigation

If not you should use a different search system such as direct Elastic, Lucene or some sort for these types of filters.

Mar 08, 2022 15:13
Ted - Mar 08, 2022 15:44
Or if it's only about filtering by month/year: automatically group the article pages under container pages, so that you can filter by invoking GetChildren() on a single container. There are many roads to Rome... :)
Scott Reed - Mar 08, 2022 17:49
I would never do it like that for any production site. Even with the in memory cache any filtering and logic can become very expensive if the number of pages is remotely large and you'd have to do a lot of caching
Anant - Mar 09, 2022 18:32
Not on DXP but I'll check the article.
Anant - Mar 09, 2022 18:34
@Ted The articles are under the container page. Any reference you can direct me to use the GetChildren() option?
Ted - Mar 10, 2022 11:27
If the only requirement is to filter by year or month - i.e. list -all- pages within that year or month - I think it would be difficult to get better performance than a single GetChildren() call. I use it quite often, and I would challenge anyone to optimize it further (for the use cases I'm using it for) at a cost acceptable to the client. :)

@Anant: GetChildren() is part of IContentLoader. You pass it a ContentReference and it returns content directly underneath it (it's not recursive). It is cached. You need to use FilterForVisitor on the child content to ensure you only return content the current user has permissions for.

Well, I second using Search & Navigation (if it's available) although there are many, many ways to achieve this.

You can easily use sorting ( with skip & take ( to achieve pagination.

I'm sure this functionality has been built a lot of times, but how you design and build it would be based on your specific requirements and stack.

Mar 08, 2022 17:21

Search & Navigation is one of the best option to achieve that.

Here are the implementations to get inspired:

Filter by Year:

Filter by Year & Category :

Edited, Mar 08, 2022 18:21
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.