This project is read-only.

How to display author name in blog posts?

Topics: Customizing Orchard, General, Writing themes
Feb 1, 2012 at 6:03 AM


I've looked for the answer to this everywhere but sadly I couldn't find anything. Basically I need to know if there is any code that would display the name of the user who made a blog entry and where to put it.

My website is (I made it for a client) and while I found a cheat way of putting in the main user's name when you click on the blog entries by putting in a line of html code into Themes>Contoso>Views>Content.cshtml this obviously doesn't work if there are multiple registered users who can make posts as it only displays the name I wrote down in my little line of code.

Any ideas? Thanks!

Feb 1, 2012 at 9:32 AM for the common part, plus some usage of Shape Tracing's Model tab should get you there.

Feb 2, 2012 at 11:06 PM

Thank you for that module, I found where to place code for displaying author name thanks to it but I couldn't find what code to use to display author's name. This is the code it uses for date and time the blog post was published:

<div class="published">@Display.PublishedState(createdDateTimeUtc: Model.ContentPart.CreatedUtc, publisheddateTimeUtc: Model.ContentPart.PublishedUtc)</div>

I've only ever worked in HTML and CSS so I know very little about CMS customization apart from editing the way certain things look, sorry for the trouble.

Feb 2, 2012 at 11:10 PM
Edited Feb 2, 2012 at 11:27 PM

Nevermind, I found a way to do it, woohoo! :D


In case this helps someone in the future the code to put down to display author name is:

<div class="authorname"><p>By: @Model.ContentPart.Owner.UserName</p></div>

Sep 7, 2013 at 12:09 AM
bertrandleroy wrote: for the common part, plus some usage of Shape Tracing's Model tab should get you there.
what kind of help is this?!?

how are you supposed to be looking for an element with shape tracing when the element you are looking for is not beeing displayed?!

and " for the common part" - what does that mean? What am I supposed to look for?

Shaking head in annoyence!
Sep 7, 2013 at 1:40 AM
Sorry for trying to help and for not being in front of your monitor. What exactly are you complaining about? You're not even the person who asked the question. Gee. Also, the author of the original question is giving you a very explicit solution. What's your problem, seriously?
Sep 7, 2013 at 10:46 AM
Sry, it was late and I have been trying to find a solution following your not very explicit advice for over an hour.

Sry for the language - I was just a bit annoyed.

Anyway, I was trying to do it via the as you suggested. However I could not find the correct code to include.

I was looking for something similar to:

<Place Parts_Comments_Count="Content:after" />

that I could put in my - as you suggested. However I could not find the correct code to display the author of a blog post.

So, pls ignore my rude comment from before.
Sep 7, 2013 at 11:59 PM
Sure, no problem.
Sep 8, 2013 at 5:55 PM
So is there any way to display the blog post author name by using the file?
Sep 8, 2013 at 8:55 PM
Yes, you need to make sure that the shape where you want the author to be rendered (typically Parts_Common_Metadata or Part_Common_Metadata_Summary) is included by placement into a zone that exists in content.cshtml, then you need to add the rendering code for the property (@Model.ContentPart.Owner.UserName here) into that template (you can discover the expression for the property using the Model tab of shape tracing).
Apr 17, 2015 at 7:50 PM
Edited Apr 17, 2015 at 7:51 PM
Hey Wota,

It's been two years, but if you haven't solved the problem here's what I'm using to get the author from the content model.
if(Model.ContentItem.BlogPostPart != null && Model.ContentItem.BlogPostPart.Creator != null) {
       postAuthor = Model.ContentItem.BlogPostPart.Creator.UserName;