Like the user's Gallery, which shows the user's avatar, I'd like to do the same in the default user's Blog.
<CS:UserAvatar runat="server" Border="0" PadImage="false" id="Avatar" />
from the Skin-GalleryTitleHeader.ascx and copied to the Skin-BlogTitleHeader.ascx, but it's not working.
Any thoughts as to why and how to fix?
You'll need to specify the User on the UserAvatar control -- you can do this using inline code, such as:
<script language="C#" runat="server">protected override void OnLoad (EventArgs e) { if (((CommunityServer.Blogs.Controls.WeblogTemplatedWebControl) this.Parent).CurrentWeblog.OwnerArray.Length > 0) userAvatar.User = CommunityServer.Users.FindUserByUsername(((CommunityServer.Blogs.Controls.WeblogTemplatedWebControl) this.Parent).CurrentWeblog.OwnerArray[0]); else userAvatar.Visible = false;}</script>
where userAvatar is the ID of the UserAvatar control and you want to display the avatar of the owner of the blog.
Got it...
Thanks Ben!
I want to add a avatar on each post in Blog/Skin-AggregateList.ascx.
I have tried your solution, but it can't apply into Blog/Skin-AggregateList.ascx.
Would you give me some suggestion?
Thanks in advance.
Dennis.
To show the avatar of the author of each post in the aggregate blog list, in Skin-AggregateList.ascx,
1. Add the following anywhere (for example, at the top of the skin file after the <%@...> declarations):
<script language="C#" runat="server">public CommunityServer.Components.User GetPostUser(CommunityServer.Components.Post post){ if (post.User != null) return post.User; else if (post.UserID > 0) return CommunityServer.Users.GetUser(post.UserID, false); else return null;}</script>
2. Add the following within the <ItemTemplate> of the <asp:Repeater id="Posts"> where you want the avatar to display:
<cs:UserAvatar runat="server" User='<%# GetPostUser ((CommunityServer.Components.Post) Container.DataItem) %>' />
Thanks Ben Tiedt.
I can displayed the avatar now.
But I have another problem for redirect to user profile when onclick that avatar.
Could you give me some hints?
To add a link around the avatar included using the changes listed above,
1. Add the following within the existing <script language="C#" runat="server"> region (created with the code above):
public string GetPostUserProfileUrl(CommunityServer.Components.Post post){ if (post.User != null && !post.User.IsAnonymous) return CommunityServer.Components.SiteUrls.Instance().UserProfile(post.User.Username); else if (post.UserID > 0 && post.UserID != CommunityServer.Users.GetAnonymousUser(true).UserID) return CommunityServer.Components.SiteUrls.Instance().UserProfile(post.UserID);return string.Empty;}
2. Add the following around the <cs:UserAvatar /> added as part of the change above:
<asp:HyperLink runat="server" NavigateUrl='<%# GetPostUserProfileUrl ((CommunityServer.Components.Post) Container.DataItem) %>'> <cs:UserAvatar /> </asp:HyperLink>
Hi there
This solution is great until you decide to have Multiple Owners for each blog
"CurrentWeblog.OwnerArray[0]);" will get you the first Owner on the List.
Is there a way to get the Username with a different method?
we already fixed the problem.
by using .CurrentWeblog.MostRecentPostAuthor
here is the idea behind this:
each Blog post can have multiple owners that can post, so the Avatar should have that spacific owner's image.
it is not the right way of doing it, but in our case the right owner was the most recent post auther.
Cheers
Genyus:If you have multiple blog owners, who's avatar should be displayed?
In the case of a blog with multiple owners, the displayed avatar should be the individual post's author. So, if you and I both are owners of a blog and I post on Tuesday, my avatar should accompany my post. If you post on Wednesday, your avatar would accompany your post. This is how it happens in the forums.
to add the User Avatar to the Skin-AboutAuthor.ascx page do the following:
Script (add it after the <%@ Import part and before the HTML part)
this is the easiest way of doing it, which is basically taking the username from the bio tag and populate the avatar with it on the Pre Render Event of the page.
Is this the same for CS07?
This is what I am trying to do...On the home page aggregate list(I have narrowed my list to Blogs only) I want to replace the "Blog" icon with the authors avatar...I also want the avatar to link to this their personal blog page(all users have a blog page).
I am very new to CS so the more detail in explaining this the better
Thanks so much
Gary
In CS2007, the <CSControl:UserAvatar /> control can be placed anywhere within the context of a user (for example, placed within the context of a post, the post's author will be displayed).
The current blogs page on cs.org (http://communityserver.org/blogs/) users this markup as the <ItemTemplate> of the <CSBlog:WeblogPostList /> control to include the user's avatar in place of the blog icon:
<li class="BlogPostArea None"> <div style="float: left; width: 70px;"> <CSControl:UserAvatar runat="server" BorderWidth="1" Width="48" Height="48" /> </div> <div style="float: left; width: 535px;"> <CSBlog:WeblogPostData Property="Subject" LinkTo="Post" Tag="H4" CssClass="BlogPostHeader" runat="server" /> <CSBlog:WeblogPostData Property="Excerpt" Tag="Div" CssClass="BlogPostContent" runat="server" /> <div class="BlogPostFooter"> <CSBlog:WeblogPostData Property="UserTime" LinkTo="Post" IncludeTimeInDate="true" Tag="Div" runat="server"><LeaderTemplate>Published </LeaderTemplate></CSBlog:WeblogPostData> </div> </div> <div style="clear: both;"></div></li>
Copyright© 2008 Telligent Systems Inc. All rights reserved CommunityServer.com • Telligent.com