Displaying owner of blog post in projection of recent blog posts

Topics: Customizing Orchard, Writing modules
Apr 15, 2013 at 11:53 PM

I've created a query of blog posts, which are posted to several blogs, using a content type filter. I would like to show some info of the creator of the post, e.g. avatar, number of total posts etc.

Is there a way I can achieve this?
Apr 17, 2013 at 1:21 AM
Apr 17, 2013 at 2:58 AM
Well, your blog posts have a CommonPart I assume. The CommonPart contains lots of juicy information you can use.
There we have the owner of your blog posts. Using this you can find all the information you want. You will probably want to create a part that on display, gets the owner from the CommonPart. Like so:
var user = ContentItem.CommonPart.Owner.ContentItem;
There you have your user ContentItem. You can then go on to get all that extra data you want to display :)
Apr 20, 2013 at 2:56 AM
Edited Apr 20, 2013 at 4:08 AM
Thank you Hazza.

I already had a custom part attached to blog posts. After your tip, I called BuildDisplay in Display method of that part's driver and added the result to the returned shape. First I wanted to return a CombinedResult but couldn't figure out how to do that with BuildDisplay. Then I added the result as a dynamic property to the shape. I think returning a combined result of shapes would be better, So I wouldn't have a Model.Display call in my view, but later maybe.
Apr 20, 2013 at 3:02 AM
Glad to hear you got it all sorted :)

And yes, I have found combined shapes to be a bit of a nightmare too.