Copied to clipboard

Flag this post as spam?

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


  • Moran 285 posts 934 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 10092 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 285 posts 934 karma points
    Feb 18, 2014 @ 11:38
    Moran
    0

    Working :)

    Thanks

Please Sign in or register to post replies

Write your reply to:

Draft