I need to add the comment function under my Articles or posts in umbraco , so i do everything to get the result , " the creation of document type called Comment with a textstring property called commentName and a textbox multiple property called commentMessage "
also I authorized the Comment document type as child document type
to mu textpage document type .
and the creation of this script in the scripting file , after that i added it below the bodyText in my template.
but
but an error message appears "Error loading MacroEngine script (file: Comment.cshtml) "
I dont knew why ?
this is the script
@using umbraco.cms.businesslogic.web
@* Some global variables *@
@{
var successfulPost = false;
var name = Request["name"];
var message = Request["message"];
}
@* Handle form post: create a new document if a valid post*@
@if (IsPost)
{
if (name!="" && message !="")
{
var dt = DocumentType.GetByAlias("Comment");
@* Make sure its a valid document type alias *@
if (dt != null)
{
var author = umbraco.BusinessLogic.User.GetUser(0);
var doc = Document.MakeNew("Comment", dt, author, Model.Id);
doc.getProperty("commentName").Value = name;
doc.getProperty("commentMessage").Value = message;
@* Tell umbraco to publish the document *@
doc.Publish(author);
umbraco.library.UpdateDocumentCache(doc.Id);
successfulPost = true;
}
comment in umbraco
I need to add the comment function under my Articles or posts in umbraco , so i do everything to get the result , " the creation of document type called Comment with a textstring property called commentName and a textbox multiple property called commentMessage " also I authorized the Comment document type as child document type to mu textpage document type .
and the creation of this script in the scripting file , after that i added it below the bodyText in my template.
but
but an error message appears "Error loading MacroEngine script (file: Comment.cshtml) "
I dont knew why ?
this is the script
@using umbraco.cms.businesslogic.web
@* Some global variables *@
@{ var successfulPost = false; var name = Request["name"]; var message = Request["message"]; }
@* Handle form post: create a new document if a valid post*@
@if (IsPost) { if (name!="" && message !="") { var dt = DocumentType.GetByAlias("Comment");
} }
@* Render the Html *@
@if (successfulPost) {
Successful post
Thank you @name for your message:
@message
}
Comments:
@foreach (dynamic c in Model.Comment) {
@c.commentMessage
By : @c.commentName (at @c.CreateDate)
}
Add a new comment:
In umbracoSettings.config change line
to
That will give you error screen with more detailed information should to debug. Also as you are using v7 how come you are not using ContentService to create the comment, Document.MakeNew is being deprecated see https://our.umbraco.org/documentation/Reference/Management-v6/Services/ContentService
Regards
Ismail
Hi khansaa111,
Perhaps you should have a look on this package. https://our.umbraco.org/projects/website-utilities/ucommentsy
Maybe it has the features that you are looking for.
Hope this helps,
/Dennis
is working on a reply...