Copied to clipboard

Flag this post as spam?

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

  • Sahar 10 posts 79 karma points
    Nov 13, 2017 @ 13:24

    Creating dynamic document Types when I save a Product in custom database.


    I m working on a Real Estate Website project using Umbraco 7.7.2 using peta pocco style to save properties in custom database. Where I am stuck at the moment is, whenever I create a property, I want a "content page" for it's detail information to be created dynamically based on an already existing document type in the Umbraco backoffice. so the editor won't have to create the detail content page manually.

    I am trying to use Content Services but no luck so far. am I going in the wrong direction. below is the code snippet I am trying right now,

            ContentType ct = new ContentType(contentType);
            ContentService cs = (ContentService)ApplicationContext.Current.Services.ContentService;
            UserService us = (UserService)ApplicationContext.Current.Services.UserService;
            Int uid = us.GetByUsername("sahar").Id;
             // Create the document  
            Content home = (Content)cs.GetById(1059);
            Content c = (Content)cs.CreateContent(nodeName, home, ct.Alias, uid);
            cs.Publish(c, uid);
            return c.Id;

    Quick help will be appreciated a lot.

    Thanks, Sahar

Please Sign in or register to post replies

Write your reply to: