+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Page creation steps using API

Page creation steps using API

8 posts, 0 answered
  1. Chetan
    Chetan avatar
    15 posts
    Registered:
    30 Aug 2012
    21 Sep 2012
    Link to this post
    Hello, I have been looking into various documentations/articles around - 
    1. How to create page dynamically 
    2. How to set custom template to the page 
    3. How to add controls (in house + custom) inside a specific place holder within assigned template
    4. and finally how to save/publish this page
    I can see various methods around each one of them (few of them are confusing for a new bee) and not sure which one should follow as a best practice. 
    e.g. Few things confuse me as a starter
    1. What's the diff using PageControl Or PageDraftControl while creating control ?
    2. The control should be added to PageData or Edit handler of page ? 
    3. Which is standard Page saving / publishing mechanism ?
    4. Is PageManager.SaveChanges() necessary every time we add a new control, can't we not do it once after adding all the controls to page ?
    5. For Publishing a page which one should we use 
    Are there any good references around each of these to follow , any examples to start with etc. ? 

  2. Chetan
    Chetan avatar
    15 posts
    Registered:
    30 Aug 2012
    24 Sep 2012
    Link to this post
    Any help regarding my query above?
  3. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    24 Sep 2012
    Link to this post
    the Sitefinity SDK has complete samples that demonstrate almost every one of these items. If you look at say the Non-Profit example, there is an additional project called sample Utilities that has a lot of helper methods showing how you can create an entire sitefinity website using the API.

    these helper methods are called from the global.asax file in the sitefinity website project, so you can see how they are used and called.

    I hope this is helpful!
  4. Pavel Benov
    Pavel Benov avatar
    341 posts
    Registered:
    14 Mar 2016
    26 Sep 2012
    Link to this post
    Hello Chetan,

    As Josh suggested you will find most of the answers of your questions in our SDK. I would also recommend going through our Documentation for further reference.

    For starters you may want to check out Content Lifecycle  and Statuses articles. I would also suggest going through this article and its sub articles. There are code samples with explanations below them for both Native and Fluent APIs on page creation, setting a template to the page, adding controls etc. 

    Regards,
    Pavel Benov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Chetan
    Chetan avatar
    15 posts
    Registered:
    30 Aug 2012
    16 Oct 2012
    Link to this post
    Hi All, I am facing another hurdle while publishing a page now - I am using below piece of code to publish the page
    var bag = new Dictionary<string, string>();
    bag.Add("ContentType", typeof(PageNode).FullName);
    WorkflowManager.MessageWorkflow(pageId, typeof(PageNode), null, "Publish", false, bag);
    At WorkflowManager.MessageWorkflow step it throws an error saying - "You are not allowed to modify this page".
    Note : I have enca[psulated this page creation code inside a WCF service, which If i ran directly from browser it goes through without any error. But if the service call gets made from a client function it throws the error while publishing.
    Am i misisng anything here? Also is teh publishing code piece right? Is there any better way Publishng a page .
    Appreciate any help on this.

    Thanks,
    Chetan
  6. Pavel Benov
    Pavel Benov avatar
    341 posts
    Registered:
    14 Mar 2016
    19 Oct 2012
    Link to this post
    Hello Chetan,

    Have you tried to suppress security checks?

    pageManager.Provider.SuppressSecurityChecks = true;

    Don't forget to set it back to false once the page is published.   Kind regards,
    Pavel Benov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. Chetan
    Chetan avatar
    15 posts
    Registered:
    30 Aug 2012
    22 Oct 2012 in reply to Pavel Benov
    Link to this post
    Thanks Pavel for the suggestion.  Even after that service throws teh same error.
    However what i observed is if i comment out my Publishing code (above 3 lines of code) then also service gets excuted without any error and we land on Edit page screen mode.
    Will this (removing publishing piece of code) cause any issue or its ok to remove it and do only
    pageManager.SaveChanges();

    Thanks,
    Chetan
  8. Pavel Benov
    Pavel Benov avatar
    341 posts
    Registered:
    14 Mar 2016
    24 Oct 2012
    Link to this post
    Hi Chetan,

    Can you submit a support ticket for this, so we can inspect this in more depth and get a better perspective on your scenario? 

    Thank you in advance.

    Greetings,
    Pavel Benov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
8 posts, 0 answered