We installed the blog 4 umbraco package, it is working as it should. But we need to put some security measures when it comes to posting comments on the blog entry. What we want to do is that when a user wants to comment on the blog post they should be logged in first and the name and email fields should be populated already with their name and email address (information is already available on the members area) after logging in.
Can we do this without the source code? Do you have any idea where I can get the soure code of the blog 4 umbraco package?
Hi the old blog4umbraco package is using a user control for the comment form. Is there a way that I can check if the user is logged in before they can give a comment to the blog post?
For the c# code you'd need to find someone else, sorry!
What you can do (and what I have done) is to create different templates for users who are and aren't logged in. One template would contain the usercontrol that allows commenting and one wouldn't. Like the following
Wow! This xslt amazes me. However I cannot understand what this xslt does. Do you have a working sample that I can view online? I'm more on the designing part, I guess I need to have someone help me with this one.
Again, I'll give it a try. Can you explain further?
Ok in the above example I've got two "blog post" templates. One of the templates includes a comment form and one has a message saying "You much be logged in to post comments". Both of these templates are allowed on the blog post page, but the default (3rd) template contains only the above macro, which takes the IDs of the two optional templates (logged in/logged out) and renders the correct one based on whether or not the user is logged in.
<!-- template ID for logged in users --> <xsl:variablename="loggedInTemplate"select="2387"/> <!-- template for logged out template --> <xsl:variablename="loggedOutTemplate"select="2388"/> <!-- current page ID --> <xsl:variablename="currentId"select="$currentPage/@id"/> <!-- is user logged in? --> <xsl:choose> <xsl:whentest="umbraco.library:IsLoggedOn()"> <xsl:value-ofselect="umbraco.library:RenderTemplate($currentId,$loggedInTemplate)"disable-output-escaping="yes"/> </xsl:when> <xsl:otherwise> <xsl:value-ofselect="umbraco.library:RenderTemplate($currentId,$loggedOutTemplate)"disable-output-escaping="yes"/> </xsl:otherwise> </xsl:choose> </xsl:template>
Lets say I have created a template already and got their ID numbers on the properties tab. Where do I place this xslt that you've created? I checked the templates for the old blog4umbraco and under the blogPost template is the Leave a Comment link.
Here is the code for the blogPost template: [code]<%@ Master Language="C#" MasterPageFile="/masterpages/BlogMaster.master" AutoEventWireup="true" %> <asp:Content ContentPlaceHolderID="head" runat="server"> <style type="text/css" media="screen">
Lets say I have created a template already and got their ID numbers on the properties tab. Where do I place this xslt that you've created? I checked the templates for the old blog4umbraco and under the blogPost template is the Leave a Comment link.
Here is the code for the blogPost template: [code] <%@ Master Language="C#" MasterPageFile="/masterpages/BlogMaster.master" AutoEventWireup="true" %> <asp:Content ContentPlaceHolderID="head" runat="server"> <style type="text/css" media="screen">
line from the copy of the template. You can replace it with a "you must be logged in" message or something.
Then I'd use the code above in a third template which will be the template actually used for the blogpost document type. Use this as your default blogpost template and all it does is decide whether or not your user is logged in, then renders the correct template in it's place. The third template is just a placeholder that chooses whether or not the user sees the template with blog comments or not.
<!-- template ID for logged in users --> <xsl:variable name="loggedInTemplate" select="2387" /> <!-- template for logged out template --> <xsl:variable name="loggedOutTemplate" select="2388" /> <!-- current page ID --> <xsl:variable name="currentId" select="$currentPage/@id" />
I thought this was going to be easy. Hehehe. Another question, where do I get the template ID? I still dont get it. Maybe it would be better to try this one first on a local site.
I was able to make the logging detection work. The problem that I'm having now is with the template. Here is a link of what is rendered when a logged in user tries to post a comment.
http://i59.photbucket.com/albums/g294/Curlybub26/blogError.jpg and when I click on the submit button to check if it posts the comment it gives me an error as well. The state information is invalid for this page and might be corrupted. I also tried to check the processed html code, as i've noticed it renders 2 forms. The extra form is because it doesn't allow me to save the loggedIn template that has the formBlogPost user control without encapsulating it on a form. I think this is just a template issue.
Hope you can help we with this one. If you have a working sample that I can view online and study, that would be a great help.
I've never seen the corrupted viewstate error before, so perhaps a trip to google is in order there
(ps sorry for missing your previous posts here) - you can get the template id by hovering over the link to edit that template in the settings section and checking the id in the querystring.
I was able to find out why the viewstate error occurs, it is because I have two forms. The problem is if I remove the form tag on the template that has the blog comment form it will give me an error. I'm pretty sure that this is just a template issue. Try to look at this. Im not loading the templates right. Here is what my templates for the blogforumbraco looks like.
Extending Blog 4 Umbraco
Hi,
We installed the blog 4 umbraco package, it is working as it should. But we need to put some security measures when it comes to posting comments on the blog entry. What we want to do is that when a user wants to comment on the blog post they should be logged in first and the name and email fields should be populated already with their name and email address (information is already available on the members area) after logging in.
Can we do this without the source code? Do you have any idea where I can get the soure code of the blog 4 umbraco package?
Do you have any idea on how to do this?
Thank you.
Regards,
Harry
Hi Harry
I haven't yet used the new blog4umbraco, but if the comment form is an xslt macro you can wrap the following function around it
Also shown is getting the current member in xslt , and at http://our.umbraco.org/wiki/reference/umbracolibrary/getmember you'll see how to access member properties.
Dan
Hi,
Thank you for your reply. I'm using the old blog for umbraco. I'll try your suggestion. Again. Thank you so much.
Regards,
Harry
Hi the old blog4umbraco package is using a user control for the comment form. Is there a way that I can check if the user is logged in before they can give a comment to the blog post?
Thank you.
Regards,
Harry
For the c# code you'd need to find someone else, sorry!
What you can do (and what I have done) is to create different templates for users who are and aren't logged in. One template would contain the usercontrol that allows commenting and one wouldn't. Like the following
RenderTemplate takes a template ID and the ID of the current page as parameters and can easily be used to do what you are after.
Dan
Wow! This xslt amazes me. However I cannot understand what this xslt does. Do you have a working sample that I can view online? I'm more on the designing part, I guess I need to have someone help me with this one.
Again, I'll give it a try. Can you explain further?
Thank you.
Regards,
Harry
No problem,
Ok in the above example I've got two "blog post" templates. One of the templates includes a comment form and one has a message saying "You much be logged in to post comments". Both of these templates are allowed on the blog post page, but the default (3rd) template contains only the above macro, which takes the IDs of the two optional templates (logged in/logged out) and renders the correct one based on whether or not the user is logged in.
Dan
Thanks again.
Lets say I have created a template already and got their ID numbers on the properties tab.
Where do I place this xslt that you've created? I checked the templates for the old blog4umbraco and under the blogPost template is the Leave a Comment link.
Here is the code for the blogPost template:
[code]<%@ Master Language="C#" MasterPageFile="/masterpages/BlogMaster.master" AutoEventWireup="true" %>
<asp:Content ContentPlaceHolderID="head" runat="server">
<style type="text/css" media="screen">
#page{ background: url("/images/kubrickbgwide.jpg") repeat-y top; border: none; }
</style>
</asp:Content>
<asp:Content ContentPlaceHolderID="body" runat="server">
<div id="content" class="widecolumn">
<div class="post">
<h2><umbraco:Item field="pageName" runat="server"></umbraco:Item></h2>
<umbraco:Item field="createDate" formatAsDate="true" runat="server"></umbraco:Item> by <umbraco:Item field="writerName" runat="server"></umbraco:Item><br/>
<div class="entrytext">
<umbraco:Item field="bodyText" runat="server"></umbraco:Item>
</div>
</div>
<umbraco:Macro Alias="BlogPostListComments" runat="server"></umbraco:Macro>
<h3 id="respond">Leave comment:</h3>
<umbraco:Macro Alias="frmBlogComment" runat="server"></umbraco:Macro>
</div>
</asp:Content>[/code]
I assume that the xslt that you gave me should be triggered after clicking the Leave a comment link.
Whoa! Im going in circles. Hehe.
Thanks again.
Lets say I have created a template already and got their ID numbers on the properties tab.
Where do I place this xslt that you've created? I checked the templates for the old blog4umbraco and under the blogPost template is the Leave a Comment link.
Here is the code for the blogPost template:
[code]
<%@ Master Language="C#" MasterPageFile="/masterpages/BlogMaster.master" AutoEventWireup="true" %>
<asp:Content ContentPlaceHolderID="head" runat="server">
<style type="text/css" media="screen">
#page{ background: url("/images/kubrickbgwide.jpg") repeat-y top; border: none; }
</style>
</asp:Content>
<asp:Content ContentPlaceHolderID="body" runat="server">
<div id="content" class="widecolumn">
<div class="post">
<h2><umbraco:Item field="pageName" runat="server"></umbraco:Item></h2>
<umbraco:Item field="createDate" formatAsDate="true" runat="server"></umbraco:Item> by <umbraco:Item field="writerName" runat="server"></umbraco:Item><br/>
<div class="entrytext">
<umbraco:Item field="bodyText" runat="server"></umbraco:Item>
</div>
</div>
<umbraco:Macro Alias="BlogPostListComments" runat="server"></umbraco:Macro>
<h3 id="respond">Leave comment:</h3>
<umbraco:Macro Alias="frmBlogComment" runat="server"></umbraco:Macro>
</div>
</asp:Content>
[/code]
I assume that the xslt that you gave me should be triggered after clicking the Leave a comment link.
Whoa! Im going in circles. Hehe.
Sorry for the double post, I cant get the code window to output the same as yours. Hehe.
There I think I got to past the code correctly. :D
Ok, so I'd duplicate the blogpost template and remove the
line from the copy of the template. You can replace it with a "you must be logged in" message or something.
Then I'd use the code above in a third template which will be the template actually used for the blogpost document type. Use this as your default blogpost template and all it does is decide whether or not your user is logged in, then renders the correct template in it's place. The third template is just a placeholder that chooses whether or not the user sees the template with blog comments or not.
Is this clearer?
Dan
Great! Thanks. I'll post again here if I have other questions. Do you have any links where I can learn great xslt? :D This is simply amazing.
Glad I could help.
http://umbraco.org/documentation/books/xslt-basics is a good start for the basics of xslt in umbraco, and installing something like (plug!) http://our.umbraco.org/projects/business-website-starter-pack or http://our.umbraco.org/projects/creative-website-starter-(cws) and looking through the sources will probably be a great help.
Dan
Hi dandrayne,
I'm getting an error when I try to create a XSLT macro for the code that you provided. Here is the whole XSLT that I did.
Please help me with this one.
Thank you.
Regards,
Harry
I thought this was going to be easy. Hehehe. Another question, where do I get the template ID? I still dont get it. Maybe it would be better to try this one first on a local site.
do i need to edit the default document type of the blog4umbraco package and include the 2 additional templates for the blogpost?
dandrayne please enlighten me.
Thank you.
Hi,
I was able to make the logging detection work. The problem that I'm having now is with the template. Here is a link of what is rendered when a logged in user tries to post a comment.
http://i59.photbucket.com/albums/g294/Curlybub26/blogError.jpg and when I click on the submit button to check if it posts the comment it gives me an error as well. The state information is invalid for this page and might be corrupted. I also tried to check the processed html code, as i've noticed it renders 2 forms. The extra form is because it doesn't allow me to save the loggedIn template that has the formBlogPost user control without encapsulating it on a form. I think this is just a template issue.
Hope you can help we with this one. If you have a working sample that I can view online and study, that would be a great help.
Thank you.
Regards,
Harry
Ooopppss! Sorry the link doesn't work. Try this.
Hi Curlybub
An example using this (and with comments working) is online at http://www.st-georges.edin.sch.uk/secondary/subjects/geography/geography-blogs/2009/12/3/expedition-2009-blog#comments
I've never seen the corrupted viewstate error before, so perhaps a trip to google is in order there
(ps sorry for missing your previous posts here) - you can get the template id by hovering over the link to edit that template in the settings section and checking the id in the querystring.
Hi Dandrayne,
I was able to find out why the viewstate error occurs, it is because I have two forms. The problem is if I remove the form tag on the template that has the blog comment form it will give me an error. I'm pretty sure that this is just a template issue. Try to look at this. Im not loading the templates right. Here is what my templates for the blogforumbraco looks like.
Template for the default blog post
Template for the blog post if user is logged in:
But when I try to post a comment it looks like this. :((
Thank you.
Regards,
Harry
Hi!
I got it working. I just used the default master page for the original blog post template. :D
Thank you so much Dandrayne!
Regards,
Harry
Phew, glad you got it sorted Harry! That was a mission ;-)
Good luck,
Dan
Hahahaha! :D
Again, thank you so much!
is working on a reply...