Join us this Friday for AI in Action at the Virtual Happy Hour! This free virtual event is open to all—enroll now on Academy and don’t miss out.
Join us this Friday for AI in Action at the Virtual Happy Hour! This free virtual event is open to all—enroll now on Academy and don’t miss out.
It is partly correct. The ContentLoader doesn't handle it when you use GetChildren to load.
However the recommended way is to use the IPublishedStateAssessor:
_contentLoader.GetChildren<EntryContent>(parentReference).Where(_publishedStateAssessor.IsPublished)
The PublishedStateAssessor will consider a lot of things including if the content hasn't been published yet, if it has expired, if it is part of a project and so on.
It is also adviced to use the Assessor instead of implementing it all yourself because Episerver might add/change how it behaves to match new functionality in the CMS.
Best Regards
Erik
Thank you. I'll take a look at the PublishedStateAssessor, because right now I'm using the CheckPublishedStatus on PageData when it's applicable for that Content - but it has some issues that looks to be much easier handled using your example.
Thanks a lot :)
Yes indeed FilterForVisitor is the best to use inside the site as it filters out by VisitorGroups as well.
It does require having a current user in the context and won't work otherwise.
I didn't see any indication in OP about what the context is, hence i gave the general filter.
Kind Regards
Erik
I've changed my code to use the PublishedStateAssessor and it looks to work very nicely for what I need it to do, so thanks a million :)
It was primarily regarding publish / expiration to begin with, but that filter looks interesting for some of our other usage - so I'll keep that in mind.
Hi.
I have a question regarding how EPiServer is handling expired pages via the ContentLoader (if at all)
I use GetChildren occasionally to extract pages from specific parents and so on - but it seems like that GetChildren cannot filter out pages that are expired, so I have to handle it manually afterwards. Is this correct?
From what I can see/ find - a page with expiration has a StopPublished date and if that date is less than / equal to my timestamp - the page is expired. Is this the correct or is there an alternative property I need to / can check instead?
Regards, and thanks in advance.