Reputation: 45
I have a multi site setup.I have to perform some functionality on a particular pagetype (article page). For this i have the below code that will allow me to loop in through all the sites. The part where I am stuck is to get the list of article pages that is available in the site i.e. getting all the article pages based on the site it is traversing.
Queue<ContentReference> todo = new Queue<ContentReference>();
siteDefinitionRepository.List().ToList().ForEach(sd =>
{
todo.Enqueue(sd.StartPage);
});
while (todo.Count > 0)
{
var siteContentReference = todo.Dequeue();
var masterContentRepository = contentRepository.Get<IContent>(siteContentReference);
var site = siteDefinitionResolver.GetByContent(masterContentRepository.ContentLink, true);
var startPage = contentLoader.Get<StartPage>(site.StartPage);
//fetch all the article pages belonging to the site within the loop
}```
Any input is helpful
Upvotes: 0
Views: 422
Reputation: 7391
You could look into using FindPagesWithCriteria
.
Be beware: it is uncached, so you need to take steps to ensure performance.
Here is an example, based on Jon Jones' blog, which retrieves all pages where the PageName
property has a specific value:
var criterias = new PropertyCriteriaCollection
{
new PropertyCriteria()
{
Name = "PageName",
Type = PropertyDataType.String,
Condition = EPiServer.Filters.CompareCondition.Equal,
Value = "Some value"
}
};
var repository = ServiceLocator.Current.GetInstance<IPageCriteriaQueryService>();
var pages = repository.FindPagesWithCriteria(
PageReference.StartPage,
criterias);
Upvotes: 0