Try our conversational search powered by Generative AI!

Getting blog owner from an entry?

Vote:
 

Hi!

I can get the author of an entry, but how do I access the owner of the blog that the entry is in?

/Peter

#55550
Dec 07, 2011 11:22
Vote:
 

Have you only got the author? Not the entry itself? From the entry it is just ((UserAuthor)eentry.Blog.Author).User (will need cast an null checks). I suppose you mean author and not Owner, Owner is most probably the MyPage for a personal blog.

#55552
Dec 07, 2011 12:32
Vote:
 

I've got both the entry and the current user. We have multiple users posting in one blog, but want the signature to say it's the "owner" of the blog that has posted. Even if we do it from moderation mode, it's still the logged in user that's posted as the author.

What I need to get is the blog's original user, not the current logged in user. But I can't figure out how to get it through the info that's available in the entry object.

#55558
Dec 07, 2011 14:40
Vote:
 

Well, that should be the Blog.Author so you can use code similar to my previous example. If the Blog.Author is not the user you want, then perhaps it should be changed? It is what that property is for.

#55559
Dec 07, 2011 14:55
Vote:
 

Hi again

That worked, thanks! But I ran into a different problem. I need to determine the BlogType that the entry is in. Do you know how to do that also? I really epreciate your help.

/Peter

#55632
Dec 09, 2011 15:41
Vote:
 

Funny, I ran into the same problem myself just the other day. Turns out I could figure it out from the Blog.OwnedBy.Context . Here's my extension method:

public static BlogType GetBlogType(this Blog blog)
{
if (blog == null) throw new ArgumentNullException("blog");

if ((blog.OwnedBy != null) && !String.IsNullOrEmpty(blog.OwnedBy.Context))
{
switch (blog.OwnedBy.Context)
{
case "Blog":
return BlogType.UserBlog;
case "GuestBook":
return BlogType.UserGuestBook;
case "NewsBlog":
return BlogType.ClubNews;
case "MessageBlog":
return BlogType.ClubMessage;
case "ExpertBlog":
return BlogType.ExpertBlog;
}
}
return BlogType.General;
}

 

#55635
Dec 09, 2011 16:00
Vote:
 

Worked perfectly! Thanks :)

/Peter

#55663
Dec 12, 2011 10:07
This thread is locked and should be used for reference only. Please use the Legacy add-ons forum to open new discussions.
* 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.