Revised coComment support
Yesterday Jayson Knight described how to add coComment support to CommunityServer. I’m a user of coComment too, therefore I added Jayson’s hack to my blog.
However, I don’t like how the URL to the blog post is rendered (it’s the rewritten URL, not the friendly one), so I decided to fix that. Furthermore, his solution does not work if you’re logged in in CommunityServer, because in this case there’s no field for the comment author’s name. No offense, Jayson, since you admitting that your implemention is only a quick hack ;)
Anyway, here’s what I came up with:
<%@ Import Namespace="CommunityServer.Components" %>
<%@ Import Namespace="CommunityServer.Blogs.Components" %>
<% WeblogPost currentPost = WeblogPosts.GetWeblogEntry(CSContext.Current.BlogGroupID, CSContext.Current.PostID); %>
<% bool isAuthor = CSContext.Current.IsAuthenticated && CSContext.Current.User.UserID == currentPost.AuthorID; %>
<script type="text/javascript">
var blogTool = "<%=SiteStatistics.CommunityServerVersionVersionInfo %>";
var blogURL = "<%=Globals.FullPath(currentPost.Weblog.HomePage) %>";
var blogTitle = "<%=currentPost.Weblog.Name %>";
var postURL = "<%=Globals.FullPath(BlogUrls.Instance().Post(currentPost)) %>";
var postTitle = "<%=currentPost.Subject %>";
var commentAuthorLoggedIn = <%=Convert.ToString(isAuthor).ToLower() %>;
<% if (isAuthor) { %>
var commentAuthor = "<%=CSContext.Current.User.DisplayName %>";
<% } else{ %>
var commentAuthorFieldName = "<%=tbName.UniqueID %>";
<% } %>
var commentFormName = "__aspnetForm";
var commentTextFieldName = "<%=tbComment.UniqueID %>";
var commentButtonName = "<%=btnSubmit.UniqueID %>";
</script>
Update: There were two bugs: the value for commentAuthorLoggedIn
was quoted and must be lower cased, and commentButtonID
must be commentButtonName
. I updated the script above.
Comments
jayson knight
lol none taken. I actually had a comment in my code noting that i needed to change that :-). Nayyeri.net stated it doesn’t work on CS2.0…I didn’t test it on 2.0 but assumed it would work. Perhaps your solution does.
Thomas Freudenberg
Hmm, at least the required variables are defined in the page’s source code. I’ll have a closer look.
Scott Elkin
This didn’t work for me. I added the code to my skin-commentform.aspx and it kept bombing on the line “bool isAuthor…”.
I have the latest CS 2.1 beta 1, ASP.NET 2.0 Version.
Keyvan Nayyeri
No, this solution doesn’t work, too.
After finishing BlogML reader, I’ll work on it myself. I didn’t change custom error page to get full detail.
Just wait untill I can find some free times ;)
Keyvan Nayyeri
Thank to you and Jayson, I modified your code to work with CS 2.0:
http://nayyeri.net/archive/…
Thomas Freudenberg
I’ve fixed the issues and updated the post. Thanks, Neyvan.
Dave Burke
Great work, Thomas! (AND Jason!) Great to see you posting on CS again, Thomas.
Keyvan Nayyeri
What did happen? CoComment didn’t work for my previous comment :(
Are you sure this works for all users?
Thomas Freudenberg
Scott, Keyvan Nayyeri modified the code to work with CS2.0 [1]. I guess the API hasn’t changed with 2.1.
[1] http://nayyeri.net/archive/…
Leave a Comment
Your email address will not be published. Required fields are marked *