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

Forums / Developing with Sitefinity / Working with pages programmatically

Working with pages programmatically

5 posts, 1 answered
  1. Amine
    Amine avatar
    6 posts
    Registered:
    28 Aug 2012
    28 Aug 2012
    Link to this post
    Hi all,

    I want to work with pages programmatically, if i want to add this code for example, where shoud i insert it?:
    // create a new instance of CmsManager with default provider
    Telerik.Cms.CmsManager cmsManager = new Telerik.Cms.CmsManager();
    // create a new page with specified title
    Telerik.Cms.ICmsPage newPage = cmsManager.CreatePage("About us");
    // optionally, we can modify the properties of new page at this
    // place, before actually saving the page
    // created page finally needs to be saved with cmsManager
    cmsManager.SavePage(newPage);

  2. Amine
    Amine avatar
    6 posts
    Registered:
    28 Aug 2012
    28 Aug 2012
    Link to this post
    Please i am new with Sitefinity, i need to know, if i am editiing my sitefinity project in Visual Studio, which files should i edit or create to execute the previous code.. Thanks in advance.
  3. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    28 Aug 2012
    Link to this post
    Hi, I think we spoke via email but I'll post our discussion here too in case anyone else has the same question.

    The code you’ve posted below is for Sitefinity 3.7, and is not compatible with the latest release. If you're using SF 4 or higher, you’ll want to use the new API.

     Sample code for creating and saving pages using code is available in the documentation: http://www.sitefinity.com/documentation/documentationarticles/developers-guide/sitefinity-essentials/pages/creating-pages

     You can either use the standard PageManager API or the FluentAPI, both methods are explained and have sample code in the page linked above.

    You could put execute this on a blank webforms page (create a test.aspx page and put it in the code behind) and run that page to execute it. You can also place it in a user control (ascx file) as a widget and drop it on a page to run it.

     Alternatively you could wrap it in a module, but this is more advanced and probably only necessary if you need something reusable. For more on module creation take a look at the testimonials intra site module example: http://www.sitefinity.com/documentation/documentationarticles/developers-guide/how-to/how-to-create-a-testimonials-intra-site-module

    Hope this is helpful!

    Answered
  4. Chanan Zass
    Chanan Zass avatar
    123 posts
    Registered:
    21 Aug 2012
    30 May 2013
    Link to this post
    Hello,

    If Mr. Morales is still around Sitefinity, how would you go about using this, or similar, code in order to upgrade your Custom 404 pages for Sitefinity 3.7 to the latest version of Sitefinity?
    Ideally, we'd like to search a certain search index for pages that may interest the visitor.
    Thanks.
  5. Stefani Tacheva
    Stefani Tacheva avatar
    718 posts
    Registered:
    06 Dec 2016
    04 Jun 2013
    Link to this post
    Hello,

    If you have created these pages inside Sitefinity 3.7 they will be migrated during the migration process. If the pages are created by code you need to recreate them using our Sitefinity documentation for pages.

    Regards,
    Stefani Tacheva
    Telerik
    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 posts, 1 answered