Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • denisedelbando 141 posts 339 karma points
    Dec 11, 2013 @ 15:22
    denisedelbando
    0

    uBlogsy Reply to Comment

    Hello All,

    I copied the controler, model and view code to create a reply to comment functionality.

    The only difference is it has a ParentID property.

    Anyway, i can't make this line to show up.

     @Html.Action("Index", "uCommentsyReplyFormSurface", new { CurrentPage, c.Id })

    I do not know how to "register" a new controller.

    Any help would be appreciated.

    Thank you.

     

  • denisedelbando 141 posts 339 karma points
    Dec 11, 2013 @ 15:40
    denisedelbando
    0

    In the controller i have:

    public class uCommentsyReplyFormSurfaceController : SurfaceController

    Then in Index Method:

     public ActionResult Index(IPublishedContent currentPage, int CommentParentID)

    then...

     return PartialView("/Views/Partials/uCommentsy/Forms/uCommentsyFormReply.cshtml", new ReplyFormModel());

     

    ReplyFormModel is the same with ContactFormModel only it has ParentID.

     

    Then in the post event:

    public ActionResult Post(ReplyFormModel model)

     

    then when it calls the submit instead of making the parent id the folder i have this:

     

    var commentsFolder = EnsureCommentsFolder(node);

     

    int parentID = commentsFolder.Id;

     

    if (commentInfo.ParentID != -1) {

    parentID = commentInfo.ParentID;

     

    }

     

    then in the View i have

    @inherits Umbraco.Web.Mvc.UmbracoViewPage<ReplyFormModel>

    and in the actual form i have

    @Html.Hidden("commentid", Model.ParentId)

     

     

    Names are:

    uCommentsyReplyFormSurface when using in @Html.Action. C# controller name is uCommentsyReplyFormSurfaceController.cs

    Model Name is ReplyFormModel with C# name as ReplyFormModel.cs

    The view is uCommentsyFormReply.cshtml

    Maybe this info might help because I know in MVC there is this naming convention.

     

    Thank  you

     


     


     


  • denisedelbando 141 posts 339 karma points
    Dec 11, 2013 @ 16:05
    denisedelbando
    0

    I got it!

    @Html.Action("Index", "uCommentsyReplyFormSurface", new { CurrentPage, CommentParentID = cid })

     

    For the ParentID, should i pass the parentid in a hidden field? If yes how do i do this ?

    I apologize. I am learning MVC on the fly.

     

  • denisedelbando 141 posts 339 karma points
    Dec 11, 2013 @ 17:09
    denisedelbando
    0

    OH YEAH!!!! I should just post stuff here. I keep getting it right when I ask. But if i dont i get stuck. Why is that?

    Anyway, to anyone who needs a reply to comment functionality. Just reuse comment model, view and controller but add additionl stuff mentioned above.

    Also, do not forget to allow comments to be a child not to uCommentsy in umbraco. 

    Also here are some corrections from 

    In the index method change return statement to:

    ReplyFormModel rfm = newReplyFormModel();

    rfm.ParentId = CommentParentID;

    return PartialView("/Views/Partials/uCommentsy/Forms/uCommentsyFormReply.cshtml", rfm);

     

    then for the view script use: Now, I am not sure if we actually need to hidden field there.

    using (Html.BeginUmbracoForm("Post", "uCommentsyReplyFormSurface", FormMethod.Post, new { @class = "uCommentsy_comment_form" }))

        {

     

            @Html.HiddenFor(x => Model.ParentId)

     

    In the Post method of your controller do not forget to add

    var commentInfo = newCommentInfo(model.ParentId, model.Name, model.Email, model.Website, model.Message, Request.IsAuthenticated, absoluteUri, DateTime.UtcNow);

    original one had no model.ParentId. Do not forget to add another property in CommentInfo class and also create a new constructor. which accepts 8 parameters instead of 7

    In the CreateComment method (being called in post by Post -> CommentService.Instance.SubmitComment method), instead of checking for -1,

    check if zero:

    var commentsFolder = EnsureCommentsFolder(node);

    int parentID = commentsFolder.Id;

    if (commentInfo.ParentID != 0) {

    parentID = commentInfo.ParentID;

     

    }

    then ofcourse use parentID variable instead of commentsFolder.Id when inserting to DB.

    Hopefully i can help someone. Now all i have to do is figure out how to display.

    Will update this post if i figure it out.

     

     

     


     


     

  • wayferer 9 posts 50 karma points
    Mar 07, 2014 @ 23:39
    wayferer
    0

    Hi avatart0ph,

    Did you manage to figure it all out?

    thanks!

Please Sign in or register to post replies

Write your reply to:

Draft