Copied to clipboard

Flag this post as spam?

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


  • Tim C 161 posts 528 karma points
    May 26, 2016 @ 03:47
    Tim C
    0

    Sorry for multiple postings, but I am going round in circles and not even sure there is a solution even by tinkering with the API.

    In a nutshell, the requirement is (on an intranet) news articles

    some of which any user (not member) can edit,

    some of which only admins (or some other way of protecting them for selected users) can edit.

    The requirement is that anyone can post a comment against any article (even if they can't edit that particular article). (ie similar to a blog),

    Viewing articles in the front end should list their comments underneath.

    They don't necessarily need to be able to see the protected articles in the CMS as I am using Frontend Editing package so they can view them in the front end and then use the 'create' button to create child documents - ie the comments. Although this doesn't work if they don't have access to edit the article - and thus my problem.

    How could this be achieved in Umbraco 7?

    Regards

  • Paul Seal 524 posts 2889 karma points MVP 6x c-trib
    May 28, 2016 @ 09:15
    Paul Seal
    101

    I would avoid having comments created as content items in Umbraco. You are essentially creating a page for every comment, which is a bad idea. Also you would have to perform a save and publish for every comment which is a bad idea for performance on your site. I would create a comments table in the database and have columns like:

    commentid, umbraconodeid, replyto_id, comment

    comment_id is the unique record id for a comment.

    umbraconodeid is the id of the article

    replytoid is the id of the comment being replied to, this could be left null if not a reply to a comment

    comment is the text of the comment

    What do you think to this approach?

    Paul

  • Tim C 161 posts 528 karma points
    May 28, 2016 @ 11:48
    Tim C
    0

    I like this approach. Would I use petapoco to save the comments (and retrieve a list of them when displaying the articles)?

    I'm think of a web service called from javascript to list the comments.

    Re petapoco - do I need to install something to use this with Umbraco?

  • Paul Seal 524 posts 2889 karma points MVP 6x c-trib
    May 28, 2016 @ 13:22
    Paul Seal
    0

    Nothing special for the poco, just something like this:

    using Umbraco.Core.Persistence;
    using Umbraco.Core.Persistence.DatabaseAnnotations;
    
    namespace CodeShare.pocos
    {
        [TableName("tbl_comments")]
        [PrimaryKey("id")]
        [ExplicitColumns]
        public class CommentRecord     {         [Column("id")]         [PrimaryKeyColumn(AutoIncrement = true)]         public int Id { get; set; }         [Column("umbraco_node_id")]         public string UmbracoNodeId { get; set; }         [Column("reply_to_id")]         public string ReplyToId { get; set; }         [Column("comment")]         public string Comment { get; set; }     } }
  • Paul Seal 524 posts 2889 karma points MVP 6x c-trib
    May 29, 2016 @ 06:57
    Paul Seal
    0

    I would also add a commentor_id to relate the comment to the id of an umbraco member.

  • Tim C 161 posts 528 karma points
    May 29, 2016 @ 08:00
    Tim C
    0

    Makes sense, Paul.

    However, I am having real trouble using PetaPoco from a class in App_code to be used in my web service

    https://our.umbraco.org/forum/extending-umbraco-and-using-the-api/77593-using-petapoco-from-my-own-web-service

    Any ideas?

  • Paul Seal 524 posts 2889 karma points MVP 6x c-trib
    May 29, 2016 @ 10:05
    Paul Seal
    0

    I would do it server side first before trying to put it into a web service to be called from javascript

  • Tim C 161 posts 528 karma points
    May 29, 2016 @ 10:27
    Tim C
    0

    You mean in a surfacecontroller (sorry, I am little hazy on the mvc stuff) and then call that from @Html.Action?

    My problem is working with hosted version of Umbraco, and I think controllers need to be compiled.

    I guess I could download Umbraco, add my controller compile with Visual Studio and upload the dll?

    (If too many questions - just ignore!!!)

    Regards

  • Paul Seal 524 posts 2889 karma points MVP 6x c-trib
    May 29, 2016 @ 13:27
    Paul Seal
    0

    If you are doing it that way I would create a separate library, so you can have your models and controllers in it and reference it from inside the view. Then when you want to deploy any changes, you are just changing this dll, not the main one for running the site.

Please Sign in or register to post replies

Write your reply to:

Draft