Copied to clipboard

Flag this post as spam?

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


  • Moran 277 posts 885 karma points
    Feb 18, 2014 @ 06:29
    Moran
    0

    create a new page from my own class

    Is is possible to create a new page from my own class and not from the controller?

    I am trying to move this code:

    var newComment = Services.ContentService.CreateContent("Comment", CurrentPage.Id, "comment");
                newComment.SetValue("visitorName", model.Name);
                newComment.SetValue("visitorEmail", model.Email);
                newComment.SetValue("visitorComment", model.Comment);
                Services.ContentService.Save(newComment);

    to my own class in order to keep the controller as clean as possible, but I don't have any access to the CreateContent method, even after I tried to add different references.

    I am using umbraco 6.1.6

  • Ismail Mayat 4511 posts 10059 karma points MVP 2x admin c-trib
    Feb 18, 2014 @ 09:14
    Ismail Mayat
    100

    Moran,

    Try ApplicationContext.Current.Services.ContentService in your class.

    Regards

    Ismail

  • Moran 277 posts 885 karma points
    Feb 18, 2014 @ 11:38
    Moran
    0

    Working :)

    Thanks

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies