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.

 

get author related artices

Vote:
 

Hi All,

I have a contact page for saving authors in my site.

I have a blog page for writing blog posts.

so when i open a blog page i want to display related blog posts of perticular author.

so how can i achive this.

#175675
Feb 27, 2017 10:43
Vote:
 

got reolved from my self, here is the coding

var pages = FindBlogPages(root, "BloggerProfile", modelPage.Property["BloggerProfile"].ToString());

public static IEnumerable<PageData> FindBlogPages(PageReference listRoot, string property, string propertyValue)
{
IEnumerable<PageData> pages;
var criterias = new PropertyCriteriaCollection
{
new PropertyCriteria()
{
Name = property,

Type = PropertyDataType.PageReference,
Condition = CompareCondition.Equal,
Value = propertyValue
}
};
var repository = ServiceLocator.Current.GetInstance<IPageCriteriaQueryService>();
pages = repository.FindPagesWithCriteria(listRoot, criterias);

return pages.Take(4);
}

#175777
Mar 01, 2017 17:14
Vote:
 

Hi, Sandeep,

Do note that FindPagesWithCriteria should be used with care, if possible, use ContentLoader instead or cache it. It comes with performance cost.

If all blogs have a common root, the pseudo code would be:

var pages = _contentLoader.GetChildren<BlogPage>().Where(p => p.BloggerProfile == propertyValue).Take(4).ToList();

BR,

Marija

#175853
Mar 04, 2017 10:44
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.